36 lines
768 B
PHP
36 lines
768 B
PHP
<?php
|
|
|
|
namespace Modules\User\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
|
use Modules\User\Traits\BelongsToUser;
|
|
|
|
class IdentityMiddle extends Pivot
|
|
{
|
|
|
|
use BelongsToUser, MorphManyTimeline;
|
|
|
|
protected $table = 'user_identity';
|
|
protected $primaryKey = 'user_id';
|
|
public $dates = [
|
|
'started_at', 'ended_at'
|
|
];
|
|
|
|
static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
self::created(function ($identity) {
|
|
if ($identity->identity->order > 1) {
|
|
$identity->addTimeline();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function identity(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Identity::class, 'identity_id');
|
|
}
|
|
|
|
} |