| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | 
							- <?php
 - 
 - namespace App\Models;
 - 
 - use Illuminate\Database\Eloquent\Casts\Attribute;
 - use Illuminate\Database\Eloquent\Factories\HasFactory;
 - use Illuminate\Database\Eloquent\Model;
 - use Illuminate\Database\Eloquent\SoftDeletes;
 - use Illuminate\Support\Facades\Storage;
 - use Spatie\Translatable\HasTranslations;
 - 
 - class Esg extends Model
 - {
 -     use HasFactory, SoftDeletes, HasTranslations;
 -     //
 -     protected $guarded = ["id"];
 -     protected $casts = [
 -         'on_top' => 'boolean'
 -     ];
 -     protected $appends = ["banner_pc_url", "banner_mobile_url"];
 - 
 -     public $translatable = ['title', 'banner_alt', 'description', 'img_alt'];
 - 
 -     public function paragraphs(){
 -         return $this->hasMany(EsgParagraph::class)->orderBy('order');
 -     }
 -     protected function bannerPcUrl(): Attribute
 -     {
 -         return Attribute::make(
 -             get: fn ($value) => is_null($this->banner_pc) ? null :Storage::disk('public')->url($this->banner_pc),
 -         );
 -     }
 - 
 -     protected function bannerMobileUrl(): Attribute
 -     {
 -         return Attribute::make(
 -             get: fn ($value) => is_null($this->banner_mobile) ? null :Storage::disk('public')->url($this->banner_mobile),
 -         );
 -     }
 - 
 -     protected function getContentByKeyword($keyword){
 -         return $this->where("keyword", $keyword)->with('paragraphs')->first();
 -     }
 - }
 
 
  |