add shipping rules
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Application extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function pages()
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationClient extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'application_clients';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationModule extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
|
||||
protected $table = 'application_modules';
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationPage extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
|
||||
protected $table = 'application_pages';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
|
||||
@@ -7,8 +7,9 @@ use Sebastienheyd\Boilerplate\Models\Permission as parentPermission;
|
||||
class Permission extends parentPermission
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Core\App\Application::class)->withDefault(['name' => '']);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -6,8 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class RoleUser extends Model
|
||||
{
|
||||
protected $table = 'role_user';
|
||||
|
||||
protected $connection = 'mysql';
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Core\Auth\User::class);
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Laratrust\Models\LaratrustTeam;
|
||||
|
||||
class Team extends LaratrustTeam
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $connection = 'mysql';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function users()
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class TeamUser extends Model
|
||||
{
|
||||
protected $table = 'team_user';
|
||||
|
||||
protected $connection = 'mysql';
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
// use HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
|
||||
use Sebastienheyd\Boilerplate\Models\User as parentUser;
|
||||
// use HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
|
||||
class User extends parentUser
|
||||
{
|
||||
// use UserHasTeams, UsersOnlineTrait;
|
||||
use AuthenticationLogable;
|
||||
|
||||
|
||||
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'last_login'];
|
||||
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'settings' => 'array',
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UserClient extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function client()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -6,8 +7,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class UserStatus extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $guarded = [];
|
||||
protected $table = "user_statuses";
|
||||
|
||||
protected $table = 'user_statuses';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function scopeByName($query, $name)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -6,8 +7,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class UserStatusTeam extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $guarded = [];
|
||||
protected $table = "user_status_teams";
|
||||
|
||||
protected $table = 'user_status_teams';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function user_status()
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Rinvex\Categories\Models\Category as parentCategory;
|
||||
|
||||
use App\Models\Shop\Article;
|
||||
use Rinvex\Categories\Models\Category as parentCategory;
|
||||
|
||||
class Category extends parentCategory
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use App\Traits\Model\HasComments;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\Model\HasComments;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
@@ -13,7 +13,7 @@ class Comment extends Model
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'is_approved' => 'boolean'
|
||||
'is_approved' => 'boolean',
|
||||
];
|
||||
|
||||
public function scopeApproved($query)
|
||||
@@ -39,7 +39,7 @@ class Comment extends Model
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function disapprove()
|
||||
{
|
||||
$this->update([
|
||||
@@ -55,11 +55,10 @@ class Comment extends Model
|
||||
return config('comments.user_model');
|
||||
}
|
||||
|
||||
if (!is_null(config('auth.providers.users.model'))) {
|
||||
if (! is_null(config('auth.providers.users.model'))) {
|
||||
return config('auth.providers.users.model');
|
||||
}
|
||||
|
||||
throw new Exception('Could not determine the commentator model name.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Media extends Model
|
||||
{
|
||||
|
||||
@@ -2,30 +2,51 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
use App\Traits\Model\HasComments;
|
||||
use App\Traits\Model\Imageable;
|
||||
|
||||
use App\Models\Botanic\Variety;
|
||||
use App\Models\Botanic\Specie;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
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\HasRelationships;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
use Categorizable, EloquentJoin, HasComments, HasRelationships, Imageable, Powerjoins, Taggable, SoftDeletes, UserStamps;
|
||||
use Categorizable;
|
||||
use EloquentJoin;
|
||||
use HasComments;
|
||||
use HasRelationships;
|
||||
use Imageable;
|
||||
use Powerjoins;
|
||||
use RevisionableTrait;
|
||||
use Taggable;
|
||||
use SoftDeletes;
|
||||
use UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_articles';
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = [
|
||||
'article_nature_id',
|
||||
'product_type',
|
||||
'product_id',
|
||||
'ref',
|
||||
'name',
|
||||
'description',
|
||||
'visible',
|
||||
'homepage',
|
||||
];
|
||||
|
||||
public function article_nature()
|
||||
{
|
||||
return $this->belongsTo(ArticleNature::class);
|
||||
@@ -84,54 +105,55 @@ class Article extends Model implements HasMedia
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByAutocomplete($query, $str)
|
||||
{
|
||||
return $query->where($this->table . '.name', 'LIKE', '%' . $str .'%');
|
||||
return $query->where($this->table.'.name', 'LIKE', '%'.$str.'%');
|
||||
}
|
||||
|
||||
public function scopeSearch($query, $str)
|
||||
{
|
||||
return $query->where($this->table . '.name', 'LIKE', '%' . $str .'%');
|
||||
return $query->where($this->table.'.name', 'LIKE', '%'.$str.'%');
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $id ? $query->where($this->table . '.article_nature_id', $id) : $query;
|
||||
return $id ? $query->where($this->table.'.article_nature_id', $id) : $query;
|
||||
}
|
||||
|
||||
public function scopeByArticleNatures($query, $ids)
|
||||
{
|
||||
return $ids ? $query->whereIn($this->table . '.article_nature_id', $ids) : $query;
|
||||
return $ids ? $query->whereIn($this->table.'.article_nature_id', $ids) : $query;
|
||||
}
|
||||
|
||||
public function scopeByCategories($query, $categories_id)
|
||||
public function scopeByCategories($query, $categoriesId)
|
||||
{
|
||||
return $categories_id ? $query->whereHas('categories', function ($query) use ($categories_id) {
|
||||
$query->whereIn('id', $categories_id);
|
||||
return $categoriesId ? $query->whereHas('categories', function ($query) use ($categoriesId) {
|
||||
$query->whereIn('id', $categoriesId);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByCategoryParent($query, $category_id)
|
||||
public function scopeByCategoryParent($query, $categoryId)
|
||||
{
|
||||
$category = Category::find($category_id);
|
||||
return $category_id ? $query->whereHas('categories', function ($query) use ($category) {
|
||||
$category = Category::find($categoryId);
|
||||
|
||||
return $categoryId ? $query->whereHas('categories', function ($query) use ($category) {
|
||||
$query->where('_lft', '>=', $category->_lft)->where('_rgt', '<=', $category->_rgt);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
public function scopeByCategory($query, $categoryId)
|
||||
{
|
||||
return $category_id ? $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('id', $category_id);
|
||||
return $categoryId ? $query->whereHas('categories', function ($query) use ($categoryId) {
|
||||
$query->where('id', $categoryId);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeBotanic($query)
|
||||
{
|
||||
return $query->whereIn($this->table . '.product_type', [Variety::class, Specie::class]);
|
||||
return $query->whereIn($this->table.'.product_type', [Variety::class, Specie::class]);
|
||||
}
|
||||
|
||||
public function scopeMerchandise($query)
|
||||
@@ -141,18 +163,18 @@ class Article extends Model implements HasMedia
|
||||
|
||||
public function scopeByProduct($query, $model)
|
||||
{
|
||||
return $model ? $query->where($this->table . '.product_type', $model) : $query;
|
||||
return $model ? $query->where($this->table.'.product_type', $model) : $query;
|
||||
}
|
||||
|
||||
public function scopeByProductId($query, $product_id)
|
||||
public function scopeByProductId($query, $productId)
|
||||
{
|
||||
return $product_id ? $query->where($this->table . '.product_id', $product_id) : $query;
|
||||
return $productId ? $query->where($this->table.'.product_id', $productId) : $query;
|
||||
}
|
||||
|
||||
public function scopeByTag($query, $tag_id)
|
||||
public function scopeByTag($query, $tagId)
|
||||
{
|
||||
return $tag_id ? $query->whereHas('tags', function ($query) use ($tag_id) {
|
||||
$query->where('id', $tag_id);
|
||||
return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) {
|
||||
$query->where('id', $tagId);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
@@ -177,20 +199,20 @@ class Article extends Model implements HasMedia
|
||||
return $query->has('offers');
|
||||
}
|
||||
|
||||
public function scopeWithAvailableOffers($query, $sale_channel_id = false)
|
||||
public function scopeWithAvailableOffers($query, $saleChannelId = false)
|
||||
{
|
||||
return $query->whereHas('offers', function ($query) use ($sale_channel_id) {
|
||||
$query->active()->byStockAvailable()->bySaleChannel($sale_channel_id);
|
||||
return $query->whereHas('offers', function ($query) use ($saleChannelId) {
|
||||
$query->active()->byStockAvailable()->bySaleChannel($saleChannelId);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeVisible($query)
|
||||
{
|
||||
return $query->where($this->table . '.visible', 1);
|
||||
return $query->where($this->table.'.visible', 1);
|
||||
}
|
||||
|
||||
public function scopeHomepage($query)
|
||||
{
|
||||
return $query->where($this->table . '.homepage', 1);
|
||||
return $query->where($this->table.'.homepage', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,22 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class ArticleNature extends Model
|
||||
{
|
||||
use HasRelationships, SoftDeletes, UserStamps;
|
||||
use HasRelationships, SoftDeletes, RevisionableTrait, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_article_natures';
|
||||
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = ['product_type', 'name', 'description'];
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
@@ -22,7 +27,7 @@ class ArticleNature extends Model
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByBotanic($query)
|
||||
@@ -37,11 +42,11 @@ class ArticleNature extends Model
|
||||
|
||||
public function scopeByProductType($query, $type)
|
||||
{
|
||||
return $query->where($this->table . '.product_type', $type);
|
||||
return $query->where($this->table.'.product_type', $type);
|
||||
}
|
||||
|
||||
public function scopeByIds($query, $ids)
|
||||
{
|
||||
return $query->whereIn($this->table . '.id', $ids);
|
||||
return $query->whereIn($this->table.'.id', $ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class ArticlePrice extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_prices';
|
||||
|
||||
public function price()
|
||||
{
|
||||
return $this->hasOne(Price::class);
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo(ArticleNature::class);
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_family_value_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Basket extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_baskets';
|
||||
|
||||
public function Offer()
|
||||
|
||||
@@ -25,17 +25,18 @@ class Categorizable extends Model
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->where($this->table . '.category_id', $category_id);
|
||||
return $query->where($this->table.'.category_id', $category_id);
|
||||
}
|
||||
|
||||
public function scopeByCategories($query, $categories_id)
|
||||
{
|
||||
return $query->whereIn($this->table . '.category_id', $categories_id);
|
||||
return $query->whereIn($this->table.'.category_id', $categories_id);
|
||||
}
|
||||
|
||||
public function scopeByCategoryParent($query, $category_id)
|
||||
{
|
||||
$category = Category::find($category_id);
|
||||
|
||||
return $query->whereHas('category', function ($query) use ($category) {
|
||||
return $query->inRange($category->_lft, $category->_rgt);
|
||||
});
|
||||
|
||||
@@ -2,23 +2,26 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
use Cesargb\Database\Support\CascadeDelete;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kalnoy\Nestedset\NestedSet;
|
||||
use Rinvex\Categories\Models\Category as parentCategory;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use Rinvex\Categories\Models\Category as parentCategory;
|
||||
use Kalnoy\Nestedset\NestedSet;
|
||||
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
|
||||
class Category extends parentCategory
|
||||
{
|
||||
use CascadeDelete, Taggable, Userstamps;
|
||||
use CascadeDelete, SoftDeletes, Taggable, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
public $translatable = [];
|
||||
|
||||
protected $cascadeDeleteMorph = ['Articles'];
|
||||
|
||||
protected $fillable = [
|
||||
'visible',
|
||||
'homepage',
|
||||
@@ -30,7 +33,6 @@ class Category extends parentCategory
|
||||
NestedSet::PARENT_ID,
|
||||
];
|
||||
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphedByMany(Article::class, 'categorizable');
|
||||
@@ -84,6 +86,7 @@ class Category extends parentCategory
|
||||
public function scopeHasAvailableOffers($query, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
|
||||
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
|
||||
$query->WithAvailableOffers($sale_channel_id);
|
||||
});
|
||||
@@ -92,6 +95,7 @@ class Category extends parentCategory
|
||||
public function scopeHasAvailableOffersByCategoryParent($query, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
|
||||
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
|
||||
$query->WithAvailableOffers($sale_channel_id);
|
||||
})->orWhereHas('descendants.articles', function ($query) use ($sale_channel_id) {
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use App\Notifications\NewUser;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
use App\Repositories\Core\DateTime;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use AuthenticationLogable, Notifiable, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_customers';
|
||||
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
protected $casts = ['email_verified_at' => 'datetime'];
|
||||
|
||||
public function addresses()
|
||||
{
|
||||
return $this->hasMany(CustomerAddress::class);
|
||||
}
|
||||
|
||||
|
||||
public function customer_deliveries()
|
||||
{
|
||||
return $this->hasMany(CustomerDelivery::class);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class CustomerAddress extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_customer_addresses';
|
||||
|
||||
public function customer()
|
||||
|
||||
@@ -7,13 +7,14 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class CustomerDelivery extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_customer_deliveries';
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
|
||||
public function delivery()
|
||||
{
|
||||
return $this->belongsTo(Delivery::class);
|
||||
@@ -21,11 +22,11 @@ class CustomerDelivery extends Model
|
||||
|
||||
public function scopeByCustomer($query, $customer_id)
|
||||
{
|
||||
return $query->where($this->table . '.customer_id', $customer_id);
|
||||
return $query->where($this->table.'.customer_id', $customer_id);
|
||||
}
|
||||
|
||||
public function scopeByDelivery($query, $customer_id)
|
||||
{
|
||||
return $query->where($this->table . '.delivery_id', $customer_id);
|
||||
return $query->where($this->table.'.delivery_id', $customer_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,35 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Delivery extends Model
|
||||
{
|
||||
use RevisionableTrait, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_deliveries';
|
||||
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = [
|
||||
'sale_channel_id',
|
||||
'active',
|
||||
'is_public',
|
||||
'at_house',
|
||||
'name',
|
||||
'description',
|
||||
'address',
|
||||
'address2',
|
||||
'zipcode',
|
||||
'country',
|
||||
'event_date_begin',
|
||||
'event_date_end',
|
||||
];
|
||||
|
||||
public function customers()
|
||||
{
|
||||
return $this->hasMany(Customer::class);
|
||||
@@ -26,17 +49,17 @@ class Delivery extends Model
|
||||
|
||||
public function scopeByActive($query, $active)
|
||||
{
|
||||
return $query->where($this->table . '.active', $active);
|
||||
return $query->where($this->table.'.active', $active);
|
||||
}
|
||||
|
||||
public function scopeByPublic($query, $is_public)
|
||||
public function scopeByPublic($query, $isPublic)
|
||||
{
|
||||
return $query->where($this->table . '.is_public', $is_public);
|
||||
return $query->where($this->table.'.is_public', $isPublic);
|
||||
}
|
||||
|
||||
public function scopeAtHouse($query)
|
||||
{
|
||||
return $query->where($this->table . '.at_house', 1);
|
||||
return $query->where($this->table.'.at_house', 1);
|
||||
}
|
||||
|
||||
public function scopeInactive()
|
||||
|
||||
@@ -3,14 +3,19 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class DeliveryPackage extends Model
|
||||
{
|
||||
use RevisionableTrait, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_delivery_packages';
|
||||
|
||||
public function scopeByWeight($query, $weight)
|
||||
{
|
||||
return $query->orderBy('weight')->where($this->table . '.weight', '>=', $weight);
|
||||
}
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = ['weight', 'weight_flyer', 'weight_packaging'];
|
||||
}
|
||||
|
||||
@@ -3,9 +3,19 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class DeliveryType extends Model
|
||||
{
|
||||
use RevisionableTrait, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_delivery_types';
|
||||
|
||||
protected $table = 'shop_delivery_types';
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = ['name'];
|
||||
}
|
||||
|
||||
@@ -3,24 +3,34 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class DeliveryTypeCalculation extends Model
|
||||
{
|
||||
use RevisionableTrait, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_delivery_type_calculations';
|
||||
|
||||
public function DeliveryType()
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = ['type_id', 'weight', 'price'];
|
||||
|
||||
public function delivery_type()
|
||||
{
|
||||
return $this->belongsTo(DeliveryType::class);
|
||||
return $this->belongsTo(DeliveryType::class, 'type_id');
|
||||
}
|
||||
|
||||
public function scopeByDeliveryType($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.type_id', $id);
|
||||
return $query->where($this->table.'.type_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByWeight($query, $weight)
|
||||
{
|
||||
return $query->orderBy('weight')->where($this->table . '.weight', '>=', $weight);
|
||||
return $query->orderBy('weight')->where($this->table.'.weight', '>=', $weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ class DistributionChannel extends Model
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_distribution_channel';
|
||||
|
||||
|
||||
public function tariff_generics()
|
||||
{
|
||||
return $this->hasMany(TariffGeneric::class);
|
||||
|
||||
@@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Homepage extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_homepages';
|
||||
|
||||
protected $table = 'shop_homepages';
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
@@ -13,8 +12,11 @@ class Invoice extends Model
|
||||
use BelongsToThrough, RevisionableTrait, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_invoices';
|
||||
|
||||
protected $revisionCreationsEnabled = false;
|
||||
|
||||
protected $keepRevisionOf = ['status', 'total_taxed', 'shipping', 'total_shipped'];
|
||||
|
||||
public function payments()
|
||||
|
||||
@@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class InvoicePayment extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_invoice_payments';
|
||||
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
|
||||
@@ -2,23 +2,32 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use App\Traits\Model\Imageable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use App\Traits\Model\Imageable;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
class Merchandise extends Model implements HasMedia
|
||||
{
|
||||
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
use Imageable, PowerJoins, RevisionableTrait, SoftDeletes, Taggable, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_merchandises';
|
||||
|
||||
protected $revisionEnabled = true;
|
||||
|
||||
protected $keepRevisionOf = [
|
||||
'producer_id',
|
||||
'name',
|
||||
'description',
|
||||
'plus',
|
||||
];
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphMany(Article::class, 'product');
|
||||
@@ -34,8 +43,8 @@ class Merchandise extends Model implements HasMedia
|
||||
return $this->morphToMany(Tag::class, 'taggable');
|
||||
}
|
||||
|
||||
public function scopeByProducer($query, $producer_id)
|
||||
public function scopeByProducer($query, $producerId)
|
||||
{
|
||||
return $query->where('producer_id', $producer_id);
|
||||
return $query->where('producer_id', $producerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
use App\Traits\Model\HasComments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use BelongsToThrough, HasComments, HasRelationships;
|
||||
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_offers';
|
||||
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
@@ -80,37 +80,37 @@ class Offer extends Model
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_id', $id);
|
||||
return $query->where($this->table.'.article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticles($query, $ids)
|
||||
{
|
||||
return $query->whereIn($this->table . '.article_id', $ids);
|
||||
return $query->whereIn($this->table.'.article_id', $ids);
|
||||
}
|
||||
|
||||
public function scopeByID($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByOffer($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.status_id', $id);
|
||||
return $query->where($this->table.'.status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByVariation($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.variation_id', $id);
|
||||
return $query->where($this->table.'.variation_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStockAvailable($query)
|
||||
{
|
||||
return $query->where($this->table . '.stock_current', '>', 0);
|
||||
return $query->where($this->table.'.stock_current', '>', 0);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $article_nature_id)
|
||||
@@ -165,16 +165,16 @@ class Offer extends Model
|
||||
public function scopeWithPriceListsBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->with([
|
||||
'price_lists' => function($query) use ($sale_channel_id) {
|
||||
'price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
}
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->with([
|
||||
'price_list_values' => function($query) use ($sale_channel_id) {
|
||||
'price_list_values' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
]);
|
||||
@@ -183,10 +183,10 @@ class Offer extends Model
|
||||
public function scopeWithPriceBySaleChannelByQuantity($query, $sale_channel_id, $quantity = 1)
|
||||
{
|
||||
return $query->with([
|
||||
'price_lists' => function($query) use ($sale_channel_id) {
|
||||
'price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'price_lists.price_list_values' => function($query) use ($quantity) {
|
||||
'price_lists.price_list_values' => function ($query) use ($quantity) {
|
||||
$query->byQuantity($quantity);
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
class Order extends Model
|
||||
@@ -12,8 +11,11 @@ class Order extends Model
|
||||
use RevisionableTrait, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_orders';
|
||||
|
||||
protected $revisionCreationsEnabled = false;
|
||||
|
||||
protected $keepRevisionOf = ['customer_address_id', 'delivery_id', 'payment_type', 'status'];
|
||||
|
||||
public function customer()
|
||||
@@ -55,7 +57,7 @@ class Order extends Model
|
||||
{
|
||||
return $query->where('uuid', $uuid);
|
||||
}
|
||||
|
||||
|
||||
public function scopeByCustomer($query, $customer_id)
|
||||
{
|
||||
return $query->where('customer_id', $customer_id);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class OrderDetail extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_order_details';
|
||||
|
||||
public function order()
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Package extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_packages';
|
||||
|
||||
public function article_family()
|
||||
@@ -31,6 +32,6 @@ class Package extends Model
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_family_id', $id);
|
||||
return $query->where($this->table.'.article_family_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Price extends Model
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_prices';
|
||||
|
||||
public function article()
|
||||
@@ -24,11 +25,11 @@ class Price extends Model
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_id', $id);
|
||||
return $query->where($this->table.'.article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_family_id', $id);
|
||||
return $query->where($this->table.'.article_family_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PriceGenericCategory extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_price_generic_categories';
|
||||
|
||||
public function article_family()
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
use App\Traits\Model\HasComments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceList extends Model
|
||||
{
|
||||
use BelongsToThrough, HasComments;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_price_lists';
|
||||
|
||||
public function tariff()
|
||||
@@ -37,17 +36,17 @@ class PriceList extends Model
|
||||
|
||||
public function scopeByTariff($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.tariff_id', $id);
|
||||
return $query->where($this->table.'.tariff_id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.sale_channel_id', $id);
|
||||
return $query->where($this->table.'.sale_channel_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.status_id', $id);
|
||||
return $query->where($this->table.'.status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
@@ -13,6 +12,7 @@ class PriceListValue extends Model
|
||||
use BelongsToThrough, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_price_list_values';
|
||||
|
||||
public function price_list()
|
||||
@@ -32,15 +32,16 @@ class PriceListValue extends Model
|
||||
|
||||
public function scopeByPriceList($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.price_list_id', $id);
|
||||
return $query->where($this->table.'.price_list_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where($this->table . '.quantity', '<=', $quantity)->first();
|
||||
return $query->orderBy('quantity', 'desc')->where($this->table.'.quantity', '<=', $quantity)->first();
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $sale_channel_id) {
|
||||
public function scopeBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->with([
|
||||
'price_list' => function ($query) use ($sale_channel_id) {
|
||||
return $query->bySaleChannel($sale_channel_id);
|
||||
|
||||
@@ -2,28 +2,27 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use App\Traits\Model\Imageable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use App\Traits\Model\Imageable;
|
||||
|
||||
class Producer extends Model implements HasMedia
|
||||
{
|
||||
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_producers';
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function Merchandises()
|
||||
{
|
||||
return $this->hasMany(Merchandise::class);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class SaleChannel extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_sale_channels';
|
||||
|
||||
public function deliveries()
|
||||
@@ -26,6 +27,6 @@ class SaleChannel extends Model
|
||||
|
||||
public function scopeByCode($query, $code)
|
||||
{
|
||||
return $query->where($this->table . '.code', $code);
|
||||
return $query->where($this->table.'.code', $code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ class Shelve extends Model
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Rinvex\Tags\Models\Tag as parentTag;
|
||||
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
use Rinvex\Tags\Models\Tag as parentTag;
|
||||
|
||||
class Tag extends parentTag
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'name',
|
||||
@@ -19,6 +18,7 @@ class Tag extends parentTag
|
||||
'group',
|
||||
'tag_group_id',
|
||||
];
|
||||
|
||||
public $translatable = [];
|
||||
|
||||
/*
|
||||
@@ -71,12 +71,12 @@ class Tag extends parentTag
|
||||
|
||||
public function scopeByGroup($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.tag_group_id', $id);
|
||||
return $query->where($this->table.'.tag_group_id', $id);
|
||||
}
|
||||
|
||||
public function scopeWithCountArticlesByCategory($query, $category_id)
|
||||
{
|
||||
return $query->withCount(['articles' => function($query) use ($category_id) {
|
||||
return $query->withCount(['articles' => function ($query) use ($category_id) {
|
||||
$query->byCategoryParent($category_id);
|
||||
}]);
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Dyrynda\Database\Support\CascadeSoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Dyrynda\Database\Support\CascadeSoftDeletes;
|
||||
|
||||
class TagGroup extends Model
|
||||
{
|
||||
use CascadeSoftDeletes, SoftDeletes;
|
||||
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'tag_groups';
|
||||
|
||||
protected $cascadeDeletes = ['tags'];
|
||||
|
||||
public function tags()
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
|
||||
use App\Traits\Model\HasComments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Tariff extends Model
|
||||
{
|
||||
use HasComments, HasRelationships, PowerJoins;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_tariffs';
|
||||
|
||||
public function offers()
|
||||
{
|
||||
return $this->hasMany(Offer::class);
|
||||
}
|
||||
|
||||
|
||||
public function sale_channel()
|
||||
{
|
||||
return $this->belongsTo(SaleChannel::class);
|
||||
@@ -48,9 +47,9 @@ class Tariff extends Model
|
||||
|
||||
public function scopeByAutocomplete($query, $str)
|
||||
{
|
||||
return $query->where($this->table . '.name', 'LIKE', "%${str}%")
|
||||
->orWhere($this->table . '.ref', 'LIKE', "${str}%")
|
||||
->orWhere($this->table . '.code', 'LIKE', "${str}%");
|
||||
return $query->where($this->table.'.name', 'LIKE', "%${str}%")
|
||||
->orWhere($this->table.'.ref', 'LIKE', "${str}%")
|
||||
->orWhere($this->table.'.code', 'LIKE', "${str}%");
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $id)
|
||||
@@ -62,12 +61,12 @@ class Tariff extends Model
|
||||
|
||||
public function scopeBySaleChannelDefault($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.sale_channel_id', $id);
|
||||
return $query->where($this->table.'.sale_channel_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.status_id', $id);
|
||||
return $query->where($this->table.'.status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByOffer($query, $id)
|
||||
|
||||
@@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class TariffUnity extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_tariff_unities';
|
||||
|
||||
|
||||
public function tariffs()
|
||||
{
|
||||
return $this->hasMany(Tariff::class);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Tax extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_taxes';
|
||||
|
||||
public function price()
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Unity extends Model
|
||||
@@ -12,6 +11,7 @@ class Unity extends Model
|
||||
use BelongsToThrough, softDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
public function package()
|
||||
@@ -26,7 +26,7 @@ class Unity extends Model
|
||||
|
||||
public function scopeByPackage($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.package_id', $id);
|
||||
return $query->where($this->table.'.package_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\Model\HasComments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Variation extends Model
|
||||
{
|
||||
use HasComments;
|
||||
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_variations';
|
||||
|
||||
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo(Package::class);
|
||||
@@ -30,6 +30,6 @@ class Variation extends Model
|
||||
|
||||
public function scopeByPackage($query, $package_id)
|
||||
{
|
||||
return $query->where($this->table . '.package_id', $package_id);
|
||||
return $query->where($this->table.'.package_id', $package_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user