File: /var/www/ipsremont-demo/app/Models/RepairChanges.php
<?php
namespace App\Models;
use App\Services\Status\StatusService;
use App\Traits\My;
use App\User;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
class RepairChanges extends BaseModel
{
use SoftDeletes, My;
protected $_status = null;
protected $fillable = [
'repair_id',
'status',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function status()
{
if (!$this->_status) {
$this->_status = StatusService::getRepairBySlug($this->status);
}
return $this->_status;
}
public function _save($repair_id, $status)
{
$this->repair_id = $repair_id;
$this->user_id = Auth::id() ?? 0;
$this->status = $status;
$this->save();
}
}