ldc-legaulois/app/Models/BreederPortrait.php
Jérémy Munsch 34da0f98a1 tons of fix
2021-05-05 15:13:33 +02:00

37 lines
848 B
PHP

<?php
namespace App\Models;
use Illuminate\Support\Facades\Storage;
class BreederPortrait extends BreederForGmap
{
protected $fillable = [
'title',
'subtitle',
'testimony',
'latitude',
'longitude',
'picture',
'status'
];
protected static function booted()
{
static::creating(function ($portrait) {
$portrait->testimony = clean($portrait->testimony);
});
static::updating(function ($portrait) {
$portrait->testimony = clean($portrait->testimony);
});
static::deleted(function ($breeder) {
Storage::disk('public')->delete($breeder->getRawOriginal('picture'));
});
}
protected function getPictureAttribute()
{
return Storage::url($this->attributes['picture']);
}
}