19 lines
363 B
PHP
19 lines
363 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Traits;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||
|
|
use App\Models\Reward;
|
||
|
|
trait HasRewards
|
||
|
|
{
|
||
|
|
public function rewards(): MorphMany
|
||
|
|
{
|
||
|
|
return $this->morphMany(Reward::class, 'rewardable');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function primaryId(): string
|
||
|
|
{
|
||
|
|
return (string)$this->getAttribute($this->primaryKey);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|