first
This commit is contained in:
44
modules/User/Models/Traits/HasLog.php
Normal file
44
modules/User/Models/Traits/HasLog.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Models\Traits;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Modules\User\Models\UserLog;
|
||||
|
||||
trait HasLog
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 库存
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/7/26 16:13
|
||||
* @return HasMany
|
||||
*/
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserLog::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/9/7 14:22
|
||||
* @param $admin
|
||||
* @param $remark
|
||||
*/
|
||||
public function addLog($admin, $remark)
|
||||
{
|
||||
$this->logs()->create([
|
||||
'user_id' => $this->getKey(),
|
||||
'admin_id' => $admin->getKey(),
|
||||
'remark' => $remark
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user