78 lines
1.4 KiB
PHP
78 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Model;
|
|
use Dyrynda\Database\Support\CascadeSoftDeletes;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class ExampleSoftDeletes extends Model
|
|
{
|
|
use SoftDeletes, CascadeSoftDeletes;
|
|
|
|
protected $table = '';
|
|
|
|
protected $cascadeDeletes = [
|
|
// Relations.
|
|
];
|
|
|
|
protected $casts = [
|
|
// ...
|
|
];
|
|
|
|
protected $fillable = [
|
|
// ...
|
|
];
|
|
|
|
protected $hidden = [
|
|
'created_at',
|
|
'created_lotacao_id',
|
|
'created_centro_custo_id',
|
|
'updated_at',
|
|
'updated_lotacao_id',
|
|
'updated_centro_custo_id',
|
|
'deleted_at',
|
|
'deleted_lotacao_id',
|
|
'deleted_centro_custo_id',
|
|
];
|
|
|
|
protected $with = [
|
|
// ...
|
|
];
|
|
|
|
protected $appends = [
|
|
// ...
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function roles()
|
|
{
|
|
return $this->belongsToMany(Role::class, 'table')
|
|
->using(RolePivot::class)
|
|
->as('pivotName')
|
|
->withPivot(/*'field_1', 'field_2', ... */)
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function post()
|
|
{
|
|
return $this->hasOne(Post::class);
|
|
}
|
|
|
|
public function comments()
|
|
{
|
|
return $this->hasMany(Comment::class);
|
|
}
|
|
|
|
public function getIsAllowedToDeleteAttribute()
|
|
{
|
|
return $this->hasNoOne([
|
|
// Relations.
|
|
]);
|
|
}
|
|
}
|