2021-07-24 14:20:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Kwaadpepper\CrudPolicies\Enums\CrudAction;
|
|
|
|
|
use Kwaadpepper\CrudPolicies\Enums\CrudType;
|
|
|
|
|
use Kwaadpepper\CrudPolicies\Traits\IsCrudModel;
|
|
|
|
|
|
|
|
|
|
class Log extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
use IsCrudModel;
|
|
|
|
|
|
|
|
|
|
protected $crudLabelColumn = 'id';
|
|
|
|
|
|
|
|
|
|
protected $crudValueColumn = 'id';
|
|
|
|
|
|
|
|
|
|
protected $fillable = ['entry'];
|
|
|
|
|
|
|
|
|
|
public function __construct($attributes = [])
|
|
|
|
|
{
|
|
|
|
|
self::$editableProperties = [
|
|
|
|
|
'id' => [
|
|
|
|
|
'label' => trans('ID'),
|
|
|
|
|
'type' => CrudType::unsignedint(),
|
|
|
|
|
'actions' => [
|
|
|
|
|
CrudAction::viewAny(),
|
|
|
|
|
CrudAction::view()
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'entry' => [
|
|
|
|
|
'label' => trans('Entrée'),
|
|
|
|
|
'type' => CrudType::text(),
|
|
|
|
|
'required' => true,
|
|
|
|
|
'nullable' => false,
|
|
|
|
|
'actions' => [
|
|
|
|
|
CrudAction::viewAny(),
|
|
|
|
|
CrudAction::view(),
|
|
|
|
|
CrudAction::create(),
|
|
|
|
|
CrudAction::update(),
|
|
|
|
|
]
|
2021-07-25 19:11:33 +02:00
|
|
|
],
|
|
|
|
|
'created_at' => [
|
|
|
|
|
'label' => trans('Créé le'),
|
|
|
|
|
'type' => CrudType::string(),
|
|
|
|
|
'actions' => [
|
|
|
|
|
CrudAction::viewAny(),
|
|
|
|
|
CrudAction::view()
|
|
|
|
|
]
|
2021-07-24 14:20:56 +02:00
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
parent::__construct($attributes);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-25 19:11:33 +02:00
|
|
|
protected static function booted()
|
|
|
|
|
{
|
|
|
|
|
static::creating(function (Log $log) {
|
|
|
|
|
$log->user()->associate(auth()->user());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-24 14:20:56 +02:00
|
|
|
public function parent()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphTo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function parentSite()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphTo('parent', 'site');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function parentProject()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphTo('parent', 'project');
|
|
|
|
|
}
|
|
|
|
|
}
|