55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Lib\ToolboxHelper;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class WhoareweContact extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are fillable.
|
|
*
|
|
* @var array
|
|
*/
|
|
#[\Override]
|
|
protected $fillable = [
|
|
'title',
|
|
'text',
|
|
'picture',
|
|
'alt_text_picture',
|
|
'link',
|
|
'link_label',
|
|
'link_new_tab',
|
|
];
|
|
|
|
/**
|
|
* The "booted" method of the model.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
static::creating(function (WhoareweContact $whoarewecontact): void {
|
|
if ($whoarewecontact->picture) {
|
|
$whoarewecontact->picture = ToolboxHelper::storeImage(
|
|
$whoarewecontact->picture,
|
|
$whoarewecontact->getTable()
|
|
);
|
|
}
|
|
});
|
|
|
|
static::updating(function (WhoareweContact $whoarewecontact): void {
|
|
if ($whoarewecontact->picture) {
|
|
$whoarewecontact->picture = ToolboxHelper::storeImage(
|
|
$whoarewecontact->picture,
|
|
$whoarewecontact->getTable()
|
|
);
|
|
}
|
|
});
|
|
parent::boot();
|
|
}
|
|
}
|