This commit is contained in:
59
api/app/Models/Example.php
Normal file
59
api/app/Models/Example.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Example extends Model
|
||||
{
|
||||
protected $table = '';
|
||||
|
||||
protected $casts = [
|
||||
// ...
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
// ...
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user