Mini Shell

Direktori : /home/funerariamayer/api/app/Models/
Upload File :
Current File : /home/funerariamayer/api/app/Models/Card.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Card extends Model
{
    use HasFactory;

    /**
     * Table name.
     * 
     * @var string
     */
    protected $table = 'card';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'name',
        'todo',
        'description',
        'due_date',
        'group_change_date',
        'group_id',
        'user_id',
    ];

    /**
     * Relationships to be loaded.
     */
    protected $with = [
        'tags',
        'users',
    ];

    /**
     * The attributes transformed to Carbon instances.
     *
     * @var array<int, string>
     */
    protected $dates = [
        'due_date',
        'group_change_date',
    ];

    /**
     * Get the group for the card.
     * 
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function group(){
        return $this->belongsTo(Group::class);
    }

    /**
     * Get the user for the card.
     * 
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user(){
        return $this->belongsTo(User::class);
    }

    /**
     * Get the tags for the card.
     * 
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function tags(){
        return $this->belongsToMany(Tag::class, 'card_tag', 'card_id', 'tag_id');
    }

    /**
     * Get the users assigned to the card.
     * 
     * @return \Illuminate\Database\Eloquent\Relations\belongsToMany
     */
    public function users(){
        return $this->belongsToMany(User::class, 'card_user', 'card_id', 'user_id');
    }
}

Zerion Mini Shell 1.0