This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?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');
}
}