Skip to content

Commit

Permalink
Changing the migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
melogail committed Oct 5, 2023
1 parent 3872233 commit 30e9c41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/app/Nova/Referral.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function fields(NovaRequest $request)
Text::make('Last Name')->sortable(),
Text::make('Email')->sortable(),
Text::make('Referral Token')->sortable(),
Number::make('# Referred Users', 'get_referrals_count')->sortable(),
Number::make('# Referred Users', 'referrals_count')->sortable(),


HasMany::make('Referral', 'getReferrals')
HasMany::make('Referral', 'referrals')
];
}

Expand Down Expand Up @@ -105,7 +105,7 @@ public function actions(NovaRequest $request)

public static function indexQuery(NovaRequest $request, $query)
{
return $query->whereNotNull('referral_token')
->withCount('getReferrals');
return $query->has('referrals')->whereNotNull('referral_token')
->withCount('referrals');
}
}
4 changes: 2 additions & 2 deletions src/database/migrations/create_referrals_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function up(): void
{
Schema::create('referrals', function (Blueprint $table) {
$table->id();
$table->string('referral_token')->nullable();
$table->foreignId('user_id');
$table->string('referral_token');
$table->string('referrer_id')->nullable();
$table->morphs('referrable')->nullable();
$table->timestamps();

});
Expand Down

0 comments on commit 30e9c41

Please sign in to comment.