芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/portpulselogistics.com/Modules/Localization/Entities/Language.php
'boolean' ]; public function registerMediaCollections(): void { $this->addMediaCollection('icon')->singleFile(); } public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 300, 300)->nonQueued(); } protected static function booted() { // when creating language static::creating(function ($language) { $language->creator_id = auth()->id(); }); // when deleted language static::deleted(function ($language) { // remove image when deleted category if ($language->image && $language->image != null) { $language->deleteFile($language->image, config('module_localization.dir_images')); } event(new LanguageDeletedEvent($language)); }); } /* ========================================= Relations ========================================= */ public function creator() { return $this->belongsTo(User::class, 'creator_id'); } /* ========================================= Scopes ========================================= */ /** * Scope a query to only include default lang. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeDefault($query) { return $query->where('is_default', 1)->first(); } /** * Scope a query to only include current lang. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeCurrent($query) { $locale = app()->getLocale() ? app()->getLocale() : 'en'; return $query->where('code', $locale)->first(); } }