37 lines
848 B
PHP
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']);
|
|
}
|
|
}
|