Mini Shell
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Group extends Model
{
use HasFactory;
/**
* Table name.
*
* @var string
*/
protected $table = 'group';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'icon',
'color',
'group_id',
];
/**
* Getter for the icon attribute.
*
* @return string
*/
public function getIconAttribute(){
return $this->attributes['icon'] ? base64_encode(file_get_contents('storage/'.$this->attributes['icon'])) : null;
}
/**
* Getter for the color attribute.
*
* @return string
*/
public function getColorAttribute(){
return $this->attributes['color'] ?? 'primary';
}
/**
* Get the cards for the group.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function cards(){
return $this->hasMany(Card::class);
}
}
Zerion Mini Shell 1.0