35 lines
855 B
PHP
35 lines
855 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Lib\Utils;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PictoBrand extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'title',
|
|
'picture',
|
|
'alt_text_picture',
|
|
'text',
|
|
];
|
|
|
|
protected static function boot()
|
|
{
|
|
static::creating(function (PictoBrand $pictoBrand) {
|
|
if ($pictoBrand->picture) {
|
|
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
|
|
}
|
|
});
|
|
|
|
static::updating(function (PictoBrand $pictoBrand) {
|
|
if ($pictoBrand->picture) {
|
|
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
|
|
}
|
|
});
|
|
parent::boot();
|
|
}
|
|
}
|