first
This commit is contained in:
36
modules/User/Models/IdentityMiddle.php
Normal file
36
modules/User/Models/IdentityMiddle.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user