wip
This commit is contained in:
47
app/Models/CMS/Forms/ContactUS.php
Normal file
47
app/Models/CMS/Forms/ContactUS.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Forms;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ContactUS extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected $table = 'contact_us';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* title - string
|
||||
* phone - string
|
||||
* content - text
|
||||
* type - string | in: website,admin,mobile_admin,mobile_app
|
||||
* user_id - int
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'phone',
|
||||
'content',
|
||||
'type',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* User that submitted form
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
25
app/Models/CMS/Marketing/Newsletter.php
Normal file
25
app/Models/CMS/Marketing/Newsletter.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Marketing;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Newsletter extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected $table = 'newsletters';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'subject',
|
||||
'content',
|
||||
'sent',
|
||||
];
|
||||
}
|
||||
23
app/Models/CMS/Marketing/NewsletterUser.php
Normal file
23
app/Models/CMS/Marketing/NewsletterUser.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Marketing;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NewsletterUser extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected $table = 'newsletter_users';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'email',
|
||||
];
|
||||
}
|
||||
246
app/Models/CMS/Media/Banner.php
Normal file
246
app/Models/CMS/Media/Banner.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Media;
|
||||
|
||||
use App\Models\Concerns\HasSchemalessAttributes;
|
||||
use App\Models\Ecommerce\Product\Brand\Brand;
|
||||
use App\Models\Ecommerce\Product\Category\Category;
|
||||
use App\Models\Ecommerce\Product\Collection\Collection;
|
||||
use App\Models\Ecommerce\Product\Product\Product;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Spatie\EloquentSortable\SortableTrait;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class Banner extends Model implements HasMedia
|
||||
{
|
||||
use HasFactory;
|
||||
use HasSchemalessAttributes;
|
||||
use HasTranslations;
|
||||
use InteractsWithMedia;
|
||||
use SortableTrait;
|
||||
|
||||
/**
|
||||
* Table
|
||||
*/
|
||||
protected $table = 'banners';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'app',
|
||||
'title',
|
||||
'description',
|
||||
'place',
|
||||
'link',
|
||||
'is_visible',
|
||||
'resource_id',
|
||||
'resource_type',
|
||||
'sort_order',
|
||||
'options',
|
||||
];
|
||||
|
||||
/**
|
||||
* Translatable attributes
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
public $translatable = ['title', 'description'];
|
||||
|
||||
/**
|
||||
* Sortable attributes
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public $sortable = [
|
||||
'order_column_name' => 'sort_order',
|
||||
'sort_when_creating' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Banner Position: First
|
||||
*/
|
||||
public const PLACE_FIRST = 'first';
|
||||
|
||||
/**
|
||||
* Banner Position: Market
|
||||
*/
|
||||
public const MARKET = 'market';
|
||||
|
||||
/**
|
||||
* Banner Position: Store
|
||||
*/
|
||||
public const STORE = 'store';
|
||||
|
||||
/**
|
||||
* Banner Position: Homepage Grids
|
||||
*/
|
||||
public const HOMEPAGE_2_GRIDS = 'homepage_2_grids';
|
||||
|
||||
/**
|
||||
* Banner Position: Homepage categories
|
||||
*/
|
||||
public const HOMEPAGE_CATEGORIES = 'homepage_categories';
|
||||
|
||||
/**
|
||||
* Media collections
|
||||
*/
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('main')
|
||||
->singleFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Media conversations
|
||||
*/
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb200x200')
|
||||
->fit(Manipulations::FIT_CONTAIN, 200, 200);
|
||||
|
||||
$this->addMediaConversion('thumb400x400')
|
||||
->fit(Manipulations::FIT_CONTAIN, 400, 400);
|
||||
|
||||
$this->addMediaConversion('thumb350x350')
|
||||
->fit(Manipulations::FIT_CONTAIN, 350, 350);
|
||||
|
||||
$this->addMediaConversion('thumb720x720')
|
||||
->fit(Manipulations::FIT_CONTAIN, 720, 720);
|
||||
|
||||
$this->addMediaConversion('thumb800x800')
|
||||
->fit(Manipulations::FIT_CONTAIN, 800, 800);
|
||||
|
||||
$this->addMediaConversion('thumb1200x1200')
|
||||
->fit(Manipulations::FIT_CONTAIN, 1200, 1200);
|
||||
|
||||
$this->addMediaConversion('thumb288x431')
|
||||
->fit(Manipulations::FIT_CONTAIN, 288, 431);
|
||||
|
||||
$this->addMediaConversion('thumb270x350')
|
||||
->fit(Manipulations::FIT_CONTAIN, 270, 350);
|
||||
}
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection
|
||||
*/
|
||||
public function collection(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Collection::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Product
|
||||
*/
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Brand
|
||||
*/
|
||||
public function brand(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Brand::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Thumbnail URL
|
||||
*/
|
||||
public function thumbnail(string $resolution = '50x50'): string
|
||||
{
|
||||
return $this->getFirstMediaUrl('main', 'thumb'.$resolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Original image
|
||||
*/
|
||||
public function image(): string
|
||||
{
|
||||
return $this->getFirstMediaUrl('main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
* @return Builder $query
|
||||
*/
|
||||
public function scopeFilter($query, $attribute, $value): Builder
|
||||
{
|
||||
return $value ? $query->where($attribute, $value) : $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text color
|
||||
*/
|
||||
public function textColor(): ?string
|
||||
{
|
||||
return $this->options->get('color');
|
||||
}
|
||||
|
||||
/**
|
||||
* Places for banner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function places(): array
|
||||
{
|
||||
return [
|
||||
'first' => __('First banner'),
|
||||
'market' => 'Market Baş sahypa',
|
||||
'store' => 'Store Baş sahypa',
|
||||
'homepage_2_grid' => __('Homepage 2 grid'),
|
||||
'homepage_categories' => __('Homepage categories'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachable resourcec to banner
|
||||
*/
|
||||
public static function attachableResources(): array
|
||||
{
|
||||
return [
|
||||
'brand' => __('Brand'),
|
||||
'category' => __('Category'),
|
||||
'collection' => __('Collection'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Related resources
|
||||
*/
|
||||
public function relatedResources()
|
||||
{
|
||||
if ($this->place === 'homepage_categories') {
|
||||
if ($this->resource_type === 'category') {
|
||||
$this->load('category');
|
||||
|
||||
return $this->category->children()->enabled()->ordered()->get();
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
181
app/Models/CMS/Media/Carousel.php
Normal file
181
app/Models/CMS/Media/Carousel.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Media;
|
||||
|
||||
use App\Models\Concerns\HasSchemalessAttributes;
|
||||
use App\Models\Ecommerce\Product\Brand\Brand;
|
||||
use App\Models\Ecommerce\Product\Category\Category;
|
||||
use App\Models\Ecommerce\Product\Collection\Collection;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Spatie\EloquentSortable\SortableTrait;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class Carousel extends Model implements HasMedia
|
||||
{
|
||||
use HasFactory;
|
||||
use HasSchemalessAttributes;
|
||||
use HasTranslations;
|
||||
use InteractsWithMedia;
|
||||
use SortableTrait;
|
||||
|
||||
/**
|
||||
* Table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'carousels';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'app',
|
||||
'title',
|
||||
'description',
|
||||
'place',
|
||||
'link',
|
||||
'is_visible',
|
||||
'resource_id',
|
||||
'resource_type',
|
||||
'sort_order',
|
||||
'options',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transtable fields
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
public array $translatable = ['title', 'description'];
|
||||
|
||||
/**
|
||||
* Sortable attributes
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public $sortable = [
|
||||
'order_column_name' => 'sort_order',
|
||||
'sort_when_creating' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection
|
||||
*/
|
||||
public function collection(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Collection::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Brand
|
||||
*/
|
||||
public function brand(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Brand::class, 'resource_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Media collections
|
||||
*/
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('main')
|
||||
->singleFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Media conversations
|
||||
*/
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb50x50')
|
||||
->width(50)
|
||||
->height(50);
|
||||
|
||||
$this->addMediaConversion('thumb350x350')
|
||||
->width(350)
|
||||
->height(350);
|
||||
|
||||
$this->addMediaConversion('thumb650x650')
|
||||
->width(650)
|
||||
->height(650);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thumbnail
|
||||
*/
|
||||
public function thumbnail(string $resolution = '50x50'): string
|
||||
{
|
||||
return $this->getFirstMediaUrl('main', 'thumb'.$resolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to filter
|
||||
*
|
||||
* @param mixed $query
|
||||
* @param string $attribute
|
||||
* @param string $value
|
||||
* @return $query
|
||||
*/
|
||||
public function scopeFilter($query, $attribute, $value): Builder
|
||||
{
|
||||
return $value ? $query->where($attribute, $value) : $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main image
|
||||
*/
|
||||
public function image(): string
|
||||
{
|
||||
return $this->getFirstMediaUrl('main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Text color
|
||||
*/
|
||||
public function textColor(): string
|
||||
{
|
||||
return $this->options->get('color') ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Places for banner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function places(): array
|
||||
{
|
||||
return [
|
||||
'homepage' => __('Homepage'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachable resourcec to banner
|
||||
*/
|
||||
public static function attachableResources(): array
|
||||
{
|
||||
return [
|
||||
'brand' => __('Brand'),
|
||||
'category' => __('Category'),
|
||||
'collection' => __('Collection'),
|
||||
];
|
||||
}
|
||||
}
|
||||
77
app/Models/CMS/Media/Gallery.php
Normal file
77
app/Models/CMS/Media/Gallery.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS\Media;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class Gallery extends Model implements HasMedia
|
||||
{
|
||||
use HasFactory;
|
||||
use HasTranslations;
|
||||
use InteractsWithMedia;
|
||||
|
||||
/**
|
||||
* Table
|
||||
*/
|
||||
protected $table = 'galleries';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
'is_visible',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
public $translatable = ['title', 'description'];
|
||||
|
||||
/**
|
||||
* Media collections
|
||||
*/
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('main')
|
||||
->singleFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Media conversations
|
||||
*/
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb')
|
||||
->width(470)
|
||||
->height(345)
|
||||
->fit(Manipulations::FIT_CONTAIN, 470, 345);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thumbnail url
|
||||
*/
|
||||
public function thumbnail(): string
|
||||
{
|
||||
return $this->getFirstMediaUrl('main', 'thumb');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for visable galleries
|
||||
*
|
||||
* @param Builder $query
|
||||
*/
|
||||
public function scopeEnabled($query): void
|
||||
{
|
||||
$query->where('is_visible', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user