feat: add all Eloquent models with relationships
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Vote extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'title', 'description', 'type',
|
||||
'related_id', 'status', 'deadline', 'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'deadline' => 'datetime',
|
||||
];
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(VoteItem::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user