Minor fixes, coding standards
This commit is contained in:
@@ -5,7 +5,8 @@ namespace App\Models\Botanic;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Genre extends Model
|
||||
{
|
||||
use SoftDeletes, Userstamps;
|
||||
|
||||
@@ -14,6 +14,7 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Variety extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
|
||||
@@ -38,10 +38,8 @@ class ApplicationClient extends Model
|
||||
|
||||
public function scopeBySlug($query, $slug)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'application', function ($query) use ($slug) {
|
||||
$query->bySlug($slug);
|
||||
}
|
||||
);
|
||||
return $query->whereHas('application', function ($query) use ($slug) {
|
||||
$query->bySlug($slug);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class PasswordSecurity extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id', 'password_expiry_days', 'password_updated_at'
|
||||
'user_id', 'password_expiry_days', 'password_updated_at',
|
||||
];
|
||||
|
||||
// set relation
|
||||
|
||||
@@ -40,16 +40,14 @@ class User extends parentUser
|
||||
|
||||
public function teams()
|
||||
{
|
||||
return $this->hasManyThrough(\App\Models\Core\Auth\Team::class, \App\Models\Core\Auth\TeamUser::class, 'user_id', 'id', 'id', 'team_id');
|
||||
return $this->hasManyThrough(Team::class, TeamUser::class, 'user_id', 'id', 'id', 'team_id');
|
||||
}
|
||||
|
||||
public function scopeByTeam($query, $id)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
}
|
||||
);
|
||||
return $query->whereHas('teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByUniqueTeam($query)
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class ArticleNature extends Model
|
||||
|
||||
@@ -32,12 +32,11 @@ class Category extends Model
|
||||
|
||||
public function CategoryTree()
|
||||
{
|
||||
return $this->belongsTo(app('rinvex.categories.category'),'category_id');
|
||||
return $this->belongsTo(app('rinvex.categories.category'), 'category_id');
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->where('category_id', $category_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Delivery extends Model
|
||||
return $this->belongsTo(SaleChannel::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
public function scopeActive()
|
||||
{
|
||||
return $this->byActive(1);
|
||||
}
|
||||
@@ -39,19 +39,18 @@ class Delivery extends Model
|
||||
return $query->where($this->table . '.at_house', 1);
|
||||
}
|
||||
|
||||
public function scopeInactive($query)
|
||||
public function scopeInactive()
|
||||
{
|
||||
return $this->byActive(0);
|
||||
}
|
||||
|
||||
public function scopeManaged($query)
|
||||
public function scopeManaged()
|
||||
{
|
||||
return $this->byPublic(0);
|
||||
}
|
||||
|
||||
public function scopePublic($query)
|
||||
public function scopePublic()
|
||||
{
|
||||
return $this->byPublic(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,17 +8,11 @@ class InvoiceItem extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
|
||||
@@ -8,17 +8,11 @@ class Order extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function Payments()
|
||||
{
|
||||
return $this->hasMany(OrderPayment::class);
|
||||
|
||||
@@ -8,9 +8,6 @@ class OrderPayment extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
|
||||
@@ -32,16 +32,16 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceListValue extends Model
|
||||
{
|
||||
use BelongsToThrough, SoftDeletes, Userstamps;
|
||||
use BelongsToThrough, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_list_values';
|
||||
|
||||
@@ -13,5 +13,4 @@ class SaleChannel extends Model
|
||||
{
|
||||
return $this->hasMany(Delivery::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
public $translatable = ['name'];
|
||||
|
||||
@@ -19,17 +18,17 @@ class Tag extends Model
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->morphedByMany(Article::class,'taggable');
|
||||
return $this->morphedByMany(Article::class, 'taggable');
|
||||
}
|
||||
|
||||
public function varieties()
|
||||
{
|
||||
return $this->morphedByMany(\App\Models\Botanic\Variety::class,'taggable');
|
||||
return $this->morphedByMany(\App\Models\Botanic\Variety::class, 'taggable');
|
||||
}
|
||||
|
||||
public function species()
|
||||
{
|
||||
return $this->morphedByMany(\App\Models\Botanic\Specie::class,'taggable');
|
||||
return $this->morphedByMany(\App\Models\Botanic\Specie::class, 'taggable');
|
||||
}
|
||||
|
||||
public function group()
|
||||
|
||||
@@ -6,12 +6,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Taggable extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function taggable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
|
||||
@@ -31,6 +31,13 @@ class Tariff extends Model
|
||||
return $this->hasMany(PriceList::class);
|
||||
}
|
||||
|
||||
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}%");
|
||||
}
|
||||
|
||||
public function scopeBySaleChanel($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.sale_channel_id', $id);
|
||||
|
||||
@@ -32,9 +32,7 @@ class Unity extends Model
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->whereHas('package', function ($query) use ($id) {
|
||||
$query->byArticleNature($id);
|
||||
}
|
||||
);
|
||||
$query->byArticleNature($id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class Variation extends Model
|
||||
{
|
||||
use HasComments;
|
||||
|
||||
Reference in New Issue
Block a user