-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline and stage management to deals
- Loading branch information
1 parent
9038450
commit 219ff1c
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Traits\IsTenantModel; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
|
||
class Stage extends Model | ||
{ | ||
use HasFactory; | ||
use IsTenantModel; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'order', | ||
'pipeline_id', | ||
]; | ||
|
||
protected $casts = [ | ||
'order' => 'integer', | ||
]; | ||
|
||
public function pipeline(): BelongsTo | ||
{ | ||
return $this->belongsTo(Pipeline::class); | ||
} | ||
|
||
public function deals(): HasMany | ||
{ | ||
return $this->hasMany(Deal::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateDealsTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('deals', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->decimal('value', 15, 2); | ||
$table->string('stage')->nullable(); | ||
$table->date('close_date')->nullable(); | ||
$table->integer('probability')->nullable(); | ||
$table->foreignId('contact_id')->nullable()->constrained()->onDelete('set null'); | ||
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('deals'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateStagesTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('stages', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->integer('order'); | ||
$table->foreignId('pipeline_id')->constrained()->onDelete('cascade'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('stages'); | ||
} | ||
} |