Skip to content

Commit

Permalink
Add custom fields for Opportunity model in CreateTeamCustomFields lis…
Browse files Browse the repository at this point in the history
…tener
  • Loading branch information
ManukMinasyan committed Feb 2, 2025
1 parent c9f3c0a commit 55508c4
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 6 deletions.
94 changes: 94 additions & 0 deletions app/Listeners/CreateTeamCustomFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\Note;
use App\Models\People;
use App\Models\User;
use App\Models\Opportunity;
use Laravel\Jetstream\Events\TeamCreated;
use Laravel\Jetstream\Features;
use Relaticle\CustomFields\Contracts\CustomsFieldsMigrators;
Expand All @@ -32,6 +33,7 @@ public function handle(TeamCreated $event): void
$this->migrator->setTenantId($team->id);

$this->createCustomFieldsForCompany();
$this->createCustomFieldsForOpportunity();
$this->createCustomFieldsForNotes();
$this->createCustomFieldsForPeople();
}
Expand Down Expand Up @@ -90,6 +92,98 @@ private function createCustomFieldsForCompany(): void
->create();
}

/**
* Create custom fields for the opportunity model.
* @return void
*/
private function createCustomFieldsForOpportunity(): void
{
// Name - Indicates the name of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::TEXT,
name: 'Name',
code: 'name',
section: 'General',
systemDefined: true
)
->create();

// Amount - Indicates the amount of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::NUMBER,
name: 'Amount',
code: 'amount',
section: 'General',
)
->create();

// Close Date - Indicates the close date of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::DATE,
name: 'Close Date',
code: 'close_date',
section: 'General'
)
->create();

// Stage - Indicates the stage of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::SELECT,
name: 'Stage',
code: 'stage',
section: 'General'
)
->options([
'Prospecting',
'Qualification',
'Needs Analysis',
'Value Proposition',
'Id. Decision Makers',
'Perception Analysis',
'Proposal/Price Quote',
'Negotiation/Review',
'Closed Won',
'Closed Lost',
])
->create();

// Company - Indicates the company of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::SELECT,
name: 'Company',
code: 'company',
section: 'General'
)
->lookupType(Company::class)
->create();

// Point of Contact - Indicates the point of contact of the opportunity
$this->migrator
->new(
model: Opportunity::class,
type: CustomFieldType::SELECT,
name: 'Point of Contact',
code: 'point_of_contact',
section: 'General'
)
->lookupType(People::class)
->create();
}

/**
* Create custom fields for the notes model.
* @return void
*/
private function createCustomFieldsForNotes(): void
{
// Title - Indicates the title of the note
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55508c4

Please sign in to comment.