add methods to get icon on article natures
This commit is contained in:
@@ -8,11 +8,17 @@ use App\Traits\Model\HasComments;
|
||||
use App\Traits\Model\Imageable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
@@ -47,22 +53,22 @@ class Article extends Model implements HasMedia
|
||||
'homepage',
|
||||
];
|
||||
|
||||
public function article_nature()
|
||||
public function article_nature(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ArticleNature::class);
|
||||
}
|
||||
|
||||
public function invoiceItems()
|
||||
public function invoiceItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function offers()
|
||||
public function offers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Offer::class);
|
||||
}
|
||||
|
||||
public function price_lists()
|
||||
public function price_lists(): HasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(
|
||||
PriceList::class,
|
||||
@@ -72,7 +78,7 @@ class Article extends Model implements HasMedia
|
||||
);
|
||||
}
|
||||
|
||||
public function prices()
|
||||
public function prices(): HasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(
|
||||
PriceListValue::class,
|
||||
@@ -82,22 +88,22 @@ class Article extends Model implements HasMedia
|
||||
);
|
||||
}
|
||||
|
||||
public function product()
|
||||
public function product(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function siblings()
|
||||
public function siblings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Article::class, 'name', 'name');
|
||||
}
|
||||
|
||||
public function tags()
|
||||
public function tags(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Tag::class, 'taggable');
|
||||
}
|
||||
|
||||
public function tariffs()
|
||||
public function tariffs(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Tariff::class, Offer::class, 'article_id', 'id', 'id', 'tariff_id');
|
||||
// return $this->belongsToMany(Tariff::class, Offer::$table, 'id', 'id', 'tariff_id', 'tariff_id');
|
||||
|
||||
@@ -3,14 +3,19 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class ArticleNature extends Model
|
||||
class ArticleNature extends Model implements HasMedia
|
||||
{
|
||||
use HasRelationships, SoftDeletes, RevisionableTrait, UserStamps;
|
||||
use HasRelationships, InteractsWithMedia, SoftDeletes, RevisionableTrait, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
@@ -20,7 +25,7 @@ class ArticleNature extends Model
|
||||
|
||||
protected $keepRevisionOf = ['product_type', 'name', 'description'];
|
||||
|
||||
public function articles()
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
}
|
||||
@@ -49,4 +54,11 @@ class ArticleNature extends Model
|
||||
{
|
||||
return $query->whereIn($this->table.'.id', $ids);
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_MAX, 60, 32)->keepOriginalImageFormat()->nonQueued();
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_MAX, 360, 192)->keepOriginalImageFormat()->nonQueued();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Basket extends Model
|
||||
{
|
||||
@@ -10,7 +11,7 @@ class Basket extends Model
|
||||
|
||||
protected $table = 'shop_baskets';
|
||||
|
||||
public function Offer()
|
||||
public function Offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,24 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Categorizable extends Model
|
||||
{
|
||||
protected $table = 'categorizables';
|
||||
|
||||
public function categorizable()
|
||||
public function categorizable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function category()
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function article()
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class, 'categorizable_id');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Models\Shop;
|
||||
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
use Cesargb\Database\Support\CascadeDelete;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kalnoy\Nestedset\NestedSet;
|
||||
use Rinvex\Categories\Models\Category as parentCategory;
|
||||
@@ -43,12 +45,12 @@ class Category extends parentCategory
|
||||
return $this->tags->articles;
|
||||
}
|
||||
|
||||
public function Parent()
|
||||
public function Parent(): HasOne
|
||||
{
|
||||
return $this->hasOne(Category::class, 'id', 'parent_id');
|
||||
}
|
||||
|
||||
public function categorizables()
|
||||
public function categorizables(): HasMany
|
||||
{
|
||||
return $this->hasMany(Categorizable::class);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Models\Shop;
|
||||
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -21,27 +23,27 @@ class Customer extends Authenticatable
|
||||
|
||||
protected $casts = ['email_verified_at' => 'datetime'];
|
||||
|
||||
public function addresses()
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerAddress::class);
|
||||
}
|
||||
|
||||
public function customer_deliveries()
|
||||
public function customer_deliveries(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerDelivery::class);
|
||||
}
|
||||
|
||||
public function deliveries()
|
||||
public function deliveries(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function orders()
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user