Minor fixes, coding standards
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
return $query->whereHas('teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByUniqueTeam($query)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -33,8 +33,6 @@ class Unity extends Model
|
||||
{
|
||||
return $query->whereHas('package', function ($query) use ($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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core\App;
|
||||
|
||||
use App\Models\Core\App\ApplicationModule;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class ApplicationModules
|
||||
{
|
||||
public static function select_all()
|
||||
|
||||
@@ -11,7 +11,6 @@ class ApplicationPages
|
||||
return $app ? $app->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();
|
||||
|
||||
@@ -16,5 +16,4 @@ class Arrays
|
||||
unset($array[$oldkey]);
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,5 +95,4 @@ class Medias
|
||||
|
||||
return "/storage/$id/conversions/$filename";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -50,5 +50,4 @@ class Deliveries
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,5 +51,4 @@ class Packages
|
||||
{
|
||||
return Package::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user