love_php/app/Models/CloseProfileHistory.php

42 lines
903 B
PHP
Raw Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CloseProfileHistory extends Model
{
//
protected $fillable = [];
protected $guarded = [];
public function create($user_id,$status,$reason = '', $operator=0){
if($status){
$r = $this::firstOrCreate(
['user_id'=>$user_id,'reason'=>$reason]
);
if($r){
$r->updated_at = date('Y-m-d h:i:s', time());
$r->reason = $reason;
$r->operator = $operator;
$r->save();
}
}else{
$this::where('user_id',$user_id)->delete();
}
return true;
}
public function operatorUser(){
return $this->hasOne(User::class,'id','operator');
}
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
}