Refactor and localize settings and resources
- Updated GeneralSettings page to include localized labels and structured sections for better organization. - Enhanced CarouselSlide, Category, Collection, and Product resources with localized model labels and improved form/table configurations. - Modified HomeController to utilize query builder for better performance and added collection items retrieval. - Updated views to reflect localized settings and improved layout for collections and footer. - Adjusted timezone and locale settings in app configuration for better regional support.
This commit is contained in:
@@ -3,18 +3,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Collection extends Model
|
||||
{
|
||||
protected $fillable = ['title', 'subtitle', 'image', 'order', 'is_active'];
|
||||
protected $fillable = ['title', 'subtitle', 'order', 'is_active'];
|
||||
|
||||
protected static function booted(): void
|
||||
public function collectionItems(): HasMany
|
||||
{
|
||||
static::deleting(function (Collection $collection) {
|
||||
if ($collection->image) {
|
||||
Storage::disk('public')->delete($collection->image);
|
||||
}
|
||||
});
|
||||
return $this->hasMany(CollectionItem::class);
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/CollectionItem.php
Normal file
26
app/Models/CollectionItem.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CollectionItem extends Model
|
||||
{
|
||||
protected $fillable = ['collection_id', 'title', 'subtitle', 'image', 'order', 'is_active'];
|
||||
|
||||
public function collection(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Collection::class);
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::deleting(function (CollectionItem $item) {
|
||||
if ($item->image) {
|
||||
Storage::disk('public')->delete($item->image);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user