From e97f54f126a01dd9307c84343fadd627a85d37a9 Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Mon, 1 Nov 2021 00:50:10 +0100 Subject: [PATCH] Minor fixes, coding standards --- app/Menu/Customers.php | 8 +-- app/Menu/Deliveries.php | 15 ++++-- app/Models/Botanic/Genre.php | 3 +- app/Models/Botanic/Variety.php | 1 + app/Models/Core/App/ApplicationClient.php | 8 ++- app/Models/Core/Auth/PasswordSecurity.php | 2 +- app/Models/Core/Auth/User.php | 10 ++-- app/Models/Shop/ArticleNature.php | 2 +- app/Models/Shop/Category.php | 3 +- app/Models/Shop/Delivery.php | 9 ++-- app/Models/Shop/InvoiceItem.php | 6 --- app/Models/Shop/Order.php | 6 --- app/Models/Shop/OrderPayment.php | 3 -- app/Models/Shop/PriceList.php | 6 +-- app/Models/Shop/PriceListValue.php | 4 +- app/Models/Shop/SaleChannel.php | 1 - app/Models/Shop/Tag.php | 7 ++- app/Models/Shop/Taggable.php | 2 - app/Models/Shop/Tariff.php | 9 +++- app/Models/Shop/Unity.php | 6 +-- app/Models/Shop/Variation.php | 1 + app/Repositories/Botanic/Families.php | 2 +- app/Repositories/Botanic/Species.php | 3 +- .../Core/App/ApplicationClients.php | 2 +- .../Core/App/ApplicationModules.php | 3 +- .../Core/App/ApplicationPages.php | 1 - app/Repositories/Core/Arrays.php | 5 +- app/Repositories/Core/Medias.php | 1 - app/Repositories/Shop/Articles.php | 50 +++++++++++++++---- app/Repositories/Shop/Categories.php | 2 +- app/Repositories/Shop/Customers.php | 2 +- app/Repositories/Shop/Deliveries.php | 3 +- app/Repositories/Shop/Invoices.php | 2 +- app/Repositories/Shop/Offers.php | 2 +- app/Repositories/Shop/Orders.php | 2 +- app/Repositories/Shop/Packages.php | 9 ++-- app/Repositories/Shop/PriceListValues.php | 2 +- app/Repositories/Shop/PriceLists.php | 4 +- app/Repositories/Shop/Prices.php | 4 +- app/Repositories/Shop/SaleChannels.php | 2 +- app/Repositories/Shop/TagGroups.php | 11 ++-- app/Repositories/Shop/TariffUnities.php | 2 +- app/Repositories/Shop/Tariffs.php | 6 +-- app/Repositories/Shop/Taxes.php | 6 +-- app/Repositories/Shop/Unities.php | 2 +- app/Repositories/Shop/Variations.php | 6 +-- composer.json | 1 + 47 files changed, 133 insertions(+), 114 deletions(-) diff --git a/app/Menu/Customers.php b/app/Menu/Customers.php index 3929c9bd..dc88e587 100644 --- a/app/Menu/Customers.php +++ b/app/Menu/Customers.php @@ -13,8 +13,10 @@ class Customers ->activeIfRoute('customers') ->order(4); - $menu->addTo('customers', __('customer.customers.name'), [ 'route' => 'Admin.Shop.Customers.index', 'permission' => 'backend_access' ]) + $menu->addTo('customers', __('customer.customers.name'), [ + 'route' => 'Admin.Shop.Customers.index', + 'permission' => 'backend_access', + ]) ->activeIfRoute(['Admin.Shop.Customers.*'])->order(1); - - } + } } diff --git a/app/Menu/Deliveries.php b/app/Menu/Deliveries.php index 94eb3166..dc72386f 100644 --- a/app/Menu/Deliveries.php +++ b/app/Menu/Deliveries.php @@ -8,15 +8,24 @@ class Deliveries { public function make(Builder $menu) { - $menu->add('Modes de vente', [ 'permission' => 'backend_access', 'icon' => 'address-card' ]) + $menu->add('Modes de vente', [ + 'permission' => 'backend_access', + 'icon' => 'address-card' + ]) ->id('sales_mode') ->activeIfRoute('sales_mode') ->order(3); - $menu->addTo('sales_mode', __('shop.sale_channels.name'), [ 'route' => 'Admin.Shop.SaleChannels.index', 'permission' => 'backend_access' ]) + $menu->addTo('sales_mode', __('shop.sale_channels.name'), [ + 'route' => 'Admin.Shop.SaleChannels.index', + 'permission' => 'backend_access', + ]) ->activeIfRoute(['Admin.Shop.SaleChannels.*'])->order(1); - $menu->addTo('sales_mode', __('shop.deliveries.title'), [ 'route' => 'Admin.Shop.Deliveries.index', 'permission' => 'backend_access' ]) + $menu->addTo('sales_mode', __('shop.deliveries.title'), [ + 'route' => 'Admin.Shop.Deliveries.index', + 'permission' => 'backend_access', + ]) ->activeIfRoute(['Admin.Shop.Deliveries.*'])->order(1); } } diff --git a/app/Models/Botanic/Genre.php b/app/Models/Botanic/Genre.php index 8aa56a25..ba90f054 100644 --- a/app/Models/Botanic/Genre.php +++ b/app/Models/Botanic/Genre.php @@ -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; diff --git a/app/Models/Botanic/Variety.php b/app/Models/Botanic/Variety.php index c9e43319..f087a718 100644 --- a/app/Models/Botanic/Variety.php +++ b/app/Models/Botanic/Variety.php @@ -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; diff --git a/app/Models/Core/App/ApplicationClient.php b/app/Models/Core/App/ApplicationClient.php index 7f5e39af..4d92b96f 100644 --- a/app/Models/Core/App/ApplicationClient.php +++ b/app/Models/Core/App/ApplicationClient.php @@ -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); + }); } } diff --git a/app/Models/Core/Auth/PasswordSecurity.php b/app/Models/Core/Auth/PasswordSecurity.php index 69a3d853..edaf3b8c 100644 --- a/app/Models/Core/Auth/PasswordSecurity.php +++ b/app/Models/Core/Auth/PasswordSecurity.php @@ -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 diff --git a/app/Models/Core/Auth/User.php b/app/Models/Core/Auth/User.php index a9ea95c0..1ad956d0 100644 --- a/app/Models/Core/Auth/User.php +++ b/app/Models/Core/Auth/User.php @@ -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) diff --git a/app/Models/Shop/ArticleNature.php b/app/Models/Shop/ArticleNature.php index fba0982f..2fac2e49 100644 --- a/app/Models/Shop/ArticleNature.php +++ b/app/Models/Shop/ArticleNature.php @@ -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 diff --git a/app/Models/Shop/Category.php b/app/Models/Shop/Category.php index 09c3c8a3..0a2a2647 100644 --- a/app/Models/Shop/Category.php +++ b/app/Models/Shop/Category.php @@ -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); } - } diff --git a/app/Models/Shop/Delivery.php b/app/Models/Shop/Delivery.php index adc1e789..aee27e14 100644 --- a/app/Models/Shop/Delivery.php +++ b/app/Models/Shop/Delivery.php @@ -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); } - } diff --git a/app/Models/Shop/InvoiceItem.php b/app/Models/Shop/InvoiceItem.php index 3d0e8911..dc153e20 100644 --- a/app/Models/Shop/InvoiceItem.php +++ b/app/Models/Shop/InvoiceItem.php @@ -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); diff --git a/app/Models/Shop/Order.php b/app/Models/Shop/Order.php index 7e3141e3..8236301a 100644 --- a/app/Models/Shop/Order.php +++ b/app/Models/Shop/Order.php @@ -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); diff --git a/app/Models/Shop/OrderPayment.php b/app/Models/Shop/OrderPayment.php index 12adcfe9..1ca9b459 100644 --- a/app/Models/Shop/OrderPayment.php +++ b/app/Models/Shop/OrderPayment.php @@ -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); diff --git a/app/Models/Shop/PriceList.php b/app/Models/Shop/PriceList.php index 4c4de2ac..91e5b9c8 100644 --- a/app/Models/Shop/PriceList.php +++ b/app/Models/Shop/PriceList.php @@ -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); } } diff --git a/app/Models/Shop/PriceListValue.php b/app/Models/Shop/PriceListValue.php index 4dc520e9..72d133f6 100644 --- a/app/Models/Shop/PriceListValue.php +++ b/app/Models/Shop/PriceListValue.php @@ -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'; diff --git a/app/Models/Shop/SaleChannel.php b/app/Models/Shop/SaleChannel.php index bd8f8395..54a20950 100644 --- a/app/Models/Shop/SaleChannel.php +++ b/app/Models/Shop/SaleChannel.php @@ -13,5 +13,4 @@ class SaleChannel extends Model { return $this->hasMany(Delivery::class); } - } diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php index affeb8fd..857abc90 100644 --- a/app/Models/Shop/Tag.php +++ b/app/Models/Shop/Tag.php @@ -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() diff --git a/app/Models/Shop/Taggable.php b/app/Models/Shop/Taggable.php index 3c1aee12..0cdef8f7 100644 --- a/app/Models/Shop/Taggable.php +++ b/app/Models/Shop/Taggable.php @@ -6,12 +6,10 @@ use Illuminate\Database\Eloquent\Model; class Taggable extends Model { - protected $guarded = ['id']; public function taggable() { return $this->morphTo(); } - } diff --git a/app/Models/Shop/Tariff.php b/app/Models/Shop/Tariff.php index 9c8e1419..aa654f7d 100644 --- a/app/Models/Shop/Tariff.php +++ b/app/Models/Shop/Tariff.php @@ -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); diff --git a/app/Models/Shop/Unity.php b/app/Models/Shop/Unity.php index 81d18c96..de66a1c6 100644 --- a/app/Models/Shop/Unity.php +++ b/app/Models/Shop/Unity.php @@ -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); + }); } - } diff --git a/app/Models/Shop/Variation.php b/app/Models/Shop/Variation.php index 4ff1d8c4..8113d796 100644 --- a/app/Models/Shop/Variation.php +++ b/app/Models/Shop/Variation.php @@ -5,6 +5,7 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; use App\Traits\HasComments; + class Variation extends Model { use HasComments; diff --git a/app/Repositories/Botanic/Families.php b/app/Repositories/Botanic/Families.php index 0303b340..cd19da2b 100644 --- a/app/Repositories/Botanic/Families.php +++ b/app/Repositories/Botanic/Families.php @@ -51,7 +51,7 @@ class Families { $id = $id ? $id : $data['id']; $item = self::get($id); - $item->update($data); + $item->update($data); return $item; } diff --git a/app/Repositories/Botanic/Species.php b/app/Repositories/Botanic/Species.php index 2c541265..5edd5898 100644 --- a/app/Repositories/Botanic/Species.php +++ b/app/Repositories/Botanic/Species.php @@ -12,7 +12,6 @@ use App\Repositories\Core\Tag; use App\Models\Botanic\Specie; use App\Exports\Botanic\SpeciesExport; - class Species { @@ -62,7 +61,7 @@ class Species unset($data['images']); unset($data['tags']); $specie = self::store($data); - self::storeImages($variety, $images); + self::storeImages($specie, $images); self::storeTags($specie, $tags); return $specie; } diff --git a/app/Repositories/Core/App/ApplicationClients.php b/app/Repositories/Core/App/ApplicationClients.php index 7c614df2..4a178cc3 100644 --- a/app/Repositories/Core/App/ApplicationClients.php +++ b/app/Repositories/Core/App/ApplicationClients.php @@ -52,7 +52,7 @@ class ApplicationClients public static function dissociateApplications($client_id, $applications) { - $client_name = \App\Repositories\Clients::getName($client_id); + $client_name = Clients::getName($client_id); foreach ($applications as $key => $application_id) { self::dissociateApplication($client_id, $application_id); } diff --git a/app/Repositories/Core/App/ApplicationModules.php b/app/Repositories/Core/App/ApplicationModules.php index e907d0bc..92fd808f 100644 --- a/app/Repositories/Core/App/ApplicationModules.php +++ b/app/Repositories/Core/App/ApplicationModules.php @@ -1,10 +1,9 @@ toArray() : null; } - // récupère toutes les pages actives pour une application public static function getActiveByApplication($application_id) { $app = ApplicationPage::active()->byApplication($application_id)->get(); diff --git a/app/Repositories/Core/Arrays.php b/app/Repositories/Core/Arrays.php index 21254edc..a605fae9 100644 --- a/app/Repositories/Core/Arrays.php +++ b/app/Repositories/Core/Arrays.php @@ -10,11 +10,10 @@ class Arrays if (is_array($value)) { $array[$key] = self::changeKeyName($value, $newkey, $oldkey); } else { - $array[$newkey] = $array[$oldkey]; + $array[$newkey] = $array[$oldkey]; } } unset($array[$oldkey]); - return $array; + return $array; } - } diff --git a/app/Repositories/Core/Medias.php b/app/Repositories/Core/Medias.php index f1257138..b404d3d4 100644 --- a/app/Repositories/Core/Medias.php +++ b/app/Repositories/Core/Medias.php @@ -95,5 +95,4 @@ class Medias return "/storage/$id/conversions/$filename"; } - } diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index c3d09fe6..617107e5 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -25,7 +25,7 @@ class Articles public static function getOptions() { - return Article::orderBy('name','asc')->pluck('name','id')->toArray(); + return Article::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); } public static function getOptionsWithNature() @@ -78,14 +78,30 @@ class Articles $product_type = $article->product_type; switch ($product_type) { case 'App\Models\Botanic\Variety': - $data[] = ['name' => 'Espèces', 'description' => Species::getDescription($article->product->specie_id), 'tags' => Species::getTags($article->product->specie_id)]; - $data[] = ['name' => 'Variétés', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()]; + $data[] = [ + 'name' => 'Espèces', + 'description' => Species::getDescription($article->product->specie_id), + 'tags' => Species::getTags($article->product->specie_id), + ]; + $data[] = [ + 'name' => 'Variétés', + 'description' => $article->product->description, + 'tags' => $article->product->tags->toArray() + ]; break; case 'App\Models\Botanic\Specie': - $data[] = ['name' => 'Espèces', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()]; + $data[] = [ + 'name' => 'Espèces', + 'description' => $article->product->description, + 'tags' => $article->product->tags->toArray() + ]; break; case 'App\Models\Shop\Merchandise': - $data[] = ['name' => 'Marchandise', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()]; + $data[] = [ + 'name' => 'Marchandise', + 'description' => $article->product->description, + 'tags' => $article->product->tags->toArray(), + ]; break; } return $data; @@ -96,16 +112,32 @@ class Articles switch ($product_type) { case 'App\Models\Botanic\Variety': $product = Varieties::get($product_id); - $data[] = ['name' => 'Espèces', 'description' => Species::getDescription($product->specie_id), 'tags' => Species::getTags($product->specie_id)]; - $data[] = ['name' => 'Variétés', 'description' => $product->description, 'tags' => $product->tags->toArray()]; + $data[] = [ + 'name' => 'Espèces', + 'description' => Species::getDescription($product->specie_id), + 'tags' => Species::getTags($product->specie_id), + ]; + $data[] = [ + 'name' => 'Variétés', + 'description' => $product->description, + 'tags' => $product->tags->toArray(), + ]; break; case 'App\Models\Botanic\Specie': $product = Species::get($product_id); - $data[] = ['name' => 'Espèces', 'description' => $product->description, 'tags' => $product->tags->toArray()]; + $data[] = [ + 'name' => 'Espèces', + 'description' => $product->description, + 'tags' => $product->tags->toArray(), + ]; break; case 'App\Models\Shop\Merchandise': $product = Merchandises::get($product_id); - $data[] = ['name' => 'Marchandise', 'description' => $product->description, 'tags' => $product->tags->toArray()]; + $data[] = [ + 'name' => 'Marchandise', + 'description' => $product->description, + 'tags' => $product->tags->toArray() + ]; break; } return $data; diff --git a/app/Repositories/Shop/Categories.php b/app/Repositories/Shop/Categories.php index 2010cfa9..02cb0346 100644 --- a/app/Repositories/Shop/Categories.php +++ b/app/Repositories/Shop/Categories.php @@ -77,7 +77,7 @@ class Categories public static function storeImage($category, $file) { - return $article->addMedia($file)->withResponsiveImages()->toMediaCollection('images'); + return $category->addMedia($file)->withResponsiveImages()->toMediaCollection('images'); } public static function getImages($id) diff --git a/app/Repositories/Shop/Customers.php b/app/Repositories/Shop/Customers.php index 9ef794ef..8ed22164 100644 --- a/app/Repositories/Shop/Customers.php +++ b/app/Repositories/Shop/Customers.php @@ -38,7 +38,7 @@ class Customers return Customer::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = isset($data['id']) ? $data['id'] : false; return Customer::find($id)->update($data); diff --git a/app/Repositories/Shop/Deliveries.php b/app/Repositories/Shop/Deliveries.php index a762e695..7e6b52d0 100644 --- a/app/Repositories/Shop/Deliveries.php +++ b/app/Repositories/Shop/Deliveries.php @@ -33,7 +33,7 @@ class Deliveries return Delivery::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $delivery = self::get($id); @@ -50,5 +50,4 @@ class Deliveries { return self::update(['active' => $active], $id); } - } diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index 5bc94351..41581467 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -38,7 +38,7 @@ class Invoices return Invoice::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = isset($data['id']) ? $data['id'] : false; return self::get($id)->update($data); diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 4e797989..425bd02f 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -39,7 +39,7 @@ class Offers return Offer::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Orders.php b/app/Repositories/Shop/Orders.php index 70f9eb30..44632053 100644 --- a/app/Repositories/Shop/Orders.php +++ b/app/Repositories/Shop/Orders.php @@ -38,7 +38,7 @@ class Orders return Order::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Packages.php b/app/Repositories/Shop/Packages.php index 670b68eb..b0cec4b5 100644 --- a/app/Repositories/Shop/Packages.php +++ b/app/Repositories/Shop/Packages.php @@ -10,7 +10,7 @@ class Packages public static function getOptions() { return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray(); - } + } public static function getAll() { @@ -30,7 +30,7 @@ class Packages public static function store($data) { $id = isset($data['id']) ? $data['id'] : false; - $item = $id ? self::update($data) : self::create($data); + $item = $id ? self::update($data) : self::create($data); return $item->id; } @@ -39,11 +39,11 @@ class Packages return Package::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); - $item->update($data); + $item->update($data); return $item; } @@ -51,5 +51,4 @@ class Packages { return Package::destroy($id); } - } diff --git a/app/Repositories/Shop/PriceListValues.php b/app/Repositories/Shop/PriceListValues.php index a7cfae31..b7457869 100644 --- a/app/Repositories/Shop/PriceListValues.php +++ b/app/Repositories/Shop/PriceListValues.php @@ -54,7 +54,7 @@ class PriceListValues return PriceListValue::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/PriceLists.php b/app/Repositories/Shop/PriceLists.php index 8b00df0c..46be7adb 100644 --- a/app/Repositories/Shop/PriceLists.php +++ b/app/Repositories/Shop/PriceLists.php @@ -28,7 +28,7 @@ class PriceLists public static function getOptions() { - return PriceList::pluck('name','id')->toArray(); + return PriceList::pluck('name', 'id')->toArray(); } public static function getAll() @@ -76,7 +76,7 @@ class PriceLists return PriceList::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Prices.php b/app/Repositories/Shop/Prices.php index 249162ca..ba37439c 100644 --- a/app/Repositories/Shop/Prices.php +++ b/app/Repositories/Shop/Prices.php @@ -16,7 +16,7 @@ class Prices public static function getByArticle($id) { $data['prices'] = Price::byArticle($id)->notGeneric()->get()->toArray(); - $data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices','generic.category'])->get()->toArray(); + $data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices', 'generic.category'])->get()->toArray(); return $data; } @@ -48,7 +48,7 @@ class Prices return Price::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/SaleChannels.php b/app/Repositories/Shop/SaleChannels.php index c58a6b4f..df1fc1e1 100644 --- a/app/Repositories/Shop/SaleChannels.php +++ b/app/Repositories/Shop/SaleChannels.php @@ -33,7 +33,7 @@ class SaleChannels return SaleChannel::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/TagGroups.php b/app/Repositories/Shop/TagGroups.php index bb9c2e32..ba83b6e7 100644 --- a/app/Repositories/Shop/TagGroups.php +++ b/app/Repositories/Shop/TagGroups.php @@ -29,8 +29,8 @@ class TagGroups $group_tags[$tag->id] = $group->name . ' - ' . $tag->name; } $tags[] = [ - 'label' => $group->name, - 'options' => $group_tags, + 'label' => $group->name, + 'options' => $group_tags, ]; } return $tags; @@ -63,9 +63,12 @@ class TagGroups return TagGroup::create($data); } - public static function update($data) + public static function update($data, $id = false) { - return TagGroup::find($id)->update($data); + $id = $id ? $id : $data['id']; + $model = self::get($id); + $model->update($data); + return $model; } public static function destroy($id) diff --git a/app/Repositories/Shop/TariffUnities.php b/app/Repositories/Shop/TariffUnities.php index bf82b30c..0a50b37b 100644 --- a/app/Repositories/Shop/TariffUnities.php +++ b/app/Repositories/Shop/TariffUnities.php @@ -33,7 +33,7 @@ class TariffUnities return TariffUnity::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Tariffs.php b/app/Repositories/Shop/Tariffs.php index 992688dc..b84cb16c 100644 --- a/app/Repositories/Shop/Tariffs.php +++ b/app/Repositories/Shop/Tariffs.php @@ -8,7 +8,7 @@ class Tariffs { public static function autocomplete($str) { - $data = Tariff::where('name', 'LIKE', "%${str}%")->orWhere('ref', 'LIKE', "${str}%")->orWhere('code', 'LIKE', "${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id'); + $data = Tariff::byAutocomplete($str)->orderBy('name')->limit(30)->get()->pluck('name', 'id'); $export = []; foreach ($data as $key => $name) { $export[] = ['value' => $key, 'text' => $name]; @@ -18,7 +18,7 @@ class Tariffs public static function getPrices($id) { - return Tariff::with(['price_lists.price_list_values','price_lists.sale_channel'])->find($id); + return Tariff::with(['price_lists.price_list_values', 'price_lists.sale_channel'])->find($id); } public static function getOptions() @@ -58,7 +58,7 @@ class Tariffs return Tariff::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Taxes.php b/app/Repositories/Shop/Taxes.php index c0d66e6f..a73c25ff 100644 --- a/app/Repositories/Shop/Taxes.php +++ b/app/Repositories/Shop/Taxes.php @@ -12,10 +12,6 @@ use App\Models\Shop\Tax; class Taxes { - public static function getDatatable() - { - return Datatables::of($model)->make(true); - } public static function getOptions() { @@ -44,7 +40,7 @@ class Taxes return Tax::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Unities.php b/app/Repositories/Shop/Unities.php index e1c21d83..86815ae1 100644 --- a/app/Repositories/Shop/Unities.php +++ b/app/Repositories/Shop/Unities.php @@ -43,7 +43,7 @@ class Unities return Unity::create($data); } - public static function update($data, $id = false) + public static function update($data, $id = false) { $id = $id ? $id : $data['id']; $item = self::get($id); diff --git a/app/Repositories/Shop/Variations.php b/app/Repositories/Shop/Variations.php index 2e9f6c67..29000378 100644 --- a/app/Repositories/Shop/Variations.php +++ b/app/Repositories/Shop/Variations.php @@ -18,7 +18,7 @@ class Variations public static function getOptions() { - $variations = Variation::with(['package','unity'])->get(); + $variations = Variation::with(['package', 'unity'])->get(); foreach ($variations as $variation) { $data[$variation->id] = self::getName($variation); } @@ -28,7 +28,7 @@ class Variations public static function getNameByID($id) { - return self::getName(sef::getFull($id)); + return self::getName(self::getFull($id)); } public static function getName($variation) @@ -48,7 +48,7 @@ class Variations public static function getFull($id) { - return Variation::with(['package','unity'])->findOrFail($id); + return Variation::with(['package', 'unity'])->findOrFail($id); } public static function get($id) diff --git a/composer.json b/composer.json index 7a9663b7..3065a93a 100644 --- a/composer.json +++ b/composer.json @@ -94,6 +94,7 @@ "enlightn/enlightn": "^1.16", "facade/ignition": "^2.9", "fakerphp/faker": "^1.13", + "fossbarrow/laravel-phpcs": "dev-main", "imanghafoori/laravel-microscope": "^1.0", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.4",