ldc-doux/app/Models/PictoBrand.php

36 lines
855 B
PHP
Raw Normal View History

2021-12-13 16:55:12 +01:00
<?php
namespace App\Models;
2021-12-15 10:09:39 +01:00
use App\Lib\Utils;
2021-12-13 16:55:12 +01:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PictoBrand extends Model
{
use HasFactory;
protected $fillable = [
'title',
'picture',
2021-12-20 14:02:37 +01:00
'alt_text_picture',
2021-12-13 16:55:12 +01:00
'text',
];
2021-12-15 10:09:39 +01:00
protected static function boot()
{
static::creating(function (PictoBrand $pictoBrand) {
if ($pictoBrand->picture) {
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
}
});
2021-12-13 16:55:12 +01:00
2021-12-15 10:09:39 +01:00
static::updating(function (PictoBrand $pictoBrand) {
if ($pictoBrand->picture) {
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
}
});
parent::boot();
}
2021-12-13 16:55:12 +01:00
}