diff --git a/app/Datatables/Admin/Shop/PriceGenericCategoriesDataTable.php b/app/Datatables/Admin/Shop/PriceGenericCategoriesDataTable.php deleted file mode 100644 index 1cd5eefc..00000000 --- a/app/Datatables/Admin/Shop/PriceGenericCategoriesDataTable.php +++ /dev/null @@ -1,28 +0,0 @@ -withCount('price_generics'); - - return $this->buildQuery($model); - } - - protected function getColumns() - { - return [ - Column::make('name')->title('Nom'), - Column::make('price_generics_count')->title('Nb Tarifs')->class('text-right'), - $this->makeColumnButtons(), - ]; - } -} diff --git a/app/Datatables/ParentDataTable.php b/app/Datatables/ParentDataTable.php index fef14091..9f921a2e 100644 --- a/app/Datatables/ParentDataTable.php +++ b/app/Datatables/ParentDataTable.php @@ -174,6 +174,13 @@ class ParentDataTable extends DataTable return "<'row pt-3 dt-toolbar-footer'<'col-md-6'i><'col-md-6'p>>"; } + protected function getColumns() + { + return [ + $this->makeColumnButtons(), + ]; + } + protected function filename(): string { return self::buildFilename($this->model_name); diff --git a/app/Http/Controllers/Admin/Botanic/FamilyController.php b/app/Http/Controllers/Admin/Botanic/FamilyController.php index df9978bb..c4cd39d6 100644 --- a/app/Http/Controllers/Admin/Botanic/FamilyController.php +++ b/app/Http/Controllers/Admin/Botanic/FamilyController.php @@ -15,7 +15,7 @@ class FamilyController extends Controller public function create() { - return view('Admin.Botanic.Families.create', $data ?? []); + return view('Admin.Botanic.Families.create'); } public function store(Request $request) @@ -26,13 +26,6 @@ class FamilyController extends Controller return redirect()->route('Admin.Botanic.Families.index'); } - public function show($id) - { - $data = Families::get($id); - - return view('Admin.Botanic.Families.view', $data); - } - public function edit($id) { $data['family'] = Families::get($id)->toArray(); @@ -44,9 +37,4 @@ class FamilyController extends Controller { return Families::destroy($id); } - - public function exportExcel() - { - return Families::exportExcel(); - } } diff --git a/app/Http/Controllers/Admin/Botanic/GenreController.php b/app/Http/Controllers/Admin/Botanic/GenreController.php index fa729a6a..e6368bc1 100644 --- a/app/Http/Controllers/Admin/Botanic/GenreController.php +++ b/app/Http/Controllers/Admin/Botanic/GenreController.php @@ -14,14 +14,9 @@ class GenreController extends Controller return $dataTable->render('Admin.Botanic.Genres.list'); } - public function getDatatable(Request $request) - { - return Genres::getDataTable($request->all()); - } - public function create() { - $data['families'] = Families::getOptions(); + $data = Genres::init(); return view('Admin.Botanic.Genres.create', $data); } @@ -34,17 +29,10 @@ class GenreController extends Controller return redirect()->route('Admin.Botanic.Genres.index'); } - public function show($id) - { - $data['genre'] = Genres::get($id); - - return view('Admin.Botanic.Genres.view', $data); - } - public function edit($id) { + $data = Genres::init(); $data['genre'] = Genres::get($id); - $data['families'] = Families::getOptions(); return view('Admin.Botanic.Genres.edit', $data); } @@ -53,9 +41,4 @@ class GenreController extends Controller { return Genres::destroy($id); } - - public function exportExcel() - { - return Genres::exportExcel(); - } } diff --git a/app/Http/Controllers/Admin/Botanic/SpecieController.php b/app/Http/Controllers/Admin/Botanic/SpecieController.php index bdb1ba89..65e2d5a8 100644 --- a/app/Http/Controllers/Admin/Botanic/SpecieController.php +++ b/app/Http/Controllers/Admin/Botanic/SpecieController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers\Admin\Botanic; use App\Datatables\Botanic\SpeciesDataTable; use App\Repositories\Botanic\Genres; use App\Repositories\Botanic\Species; -use App\Repositories\Shop\TagGroups; use Illuminate\Http\Request; class SpecieController extends Controller @@ -22,8 +21,7 @@ class SpecieController extends Controller public function create() { - $data['genres'] = Genres::getOptions(); - $data['tags_list'] = TagGroups::getTreeTags(); + $data = Genres::init(); return view('Admin.Botanic.Species.create', $data); } @@ -36,18 +34,10 @@ class SpecieController extends Controller return redirect()->route('Admin.Botanic.Species.index'); } - public function show($id) - { - $data = Species::get($id); - - return view('Admin.Botanic.Species.view', $data); - } - public function edit($id) { + $data = Genres::init(); $data['specie'] = Species::getFull($id); - $data['genres'] = Genres::getOptions(); - $data['tags_list'] = TagGroups::getTreeTags(); return view('Admin.Botanic.Species.edit', $data); } @@ -60,8 +50,10 @@ class SpecieController extends Controller public function getImages(Request $request, $id = false, $can_edit = true) { $id = $id ? $id : $request->input('id'); - $data['images'] = Species::getImages($id); - $data['can_edit'] = $can_edit; + $data = [ + 'images' => Species::getImages($id), + 'can_edit' => $can_edit, + ]; return view('components.uploader.mini-gallery-items', $data); } @@ -73,9 +65,4 @@ class SpecieController extends Controller return Species::deleteImage($id, $index); } - - public function exportExcel() - { - return Species::exportExcel(); - } } diff --git a/app/Http/Controllers/Admin/Botanic/VarietyController.php b/app/Http/Controllers/Admin/Botanic/VarietyController.php index 36bfeac5..61bd7e7a 100644 --- a/app/Http/Controllers/Admin/Botanic/VarietyController.php +++ b/app/Http/Controllers/Admin/Botanic/VarietyController.php @@ -22,8 +22,7 @@ class VarietyController extends Controller public function create() { - $data['species'] = Species::getOptions(); - $data['tags_list'] = TagGroups::getTreeTags(); + $data = Varieties::init(); return view('Admin.Botanic.Varieties.create', $data); } @@ -36,16 +35,10 @@ class VarietyController extends Controller return redirect()->route('Admin.Botanic.Varieties.index'); } - public function show($id) - { - return view('Admin.Botanic.Varieties.view', Varieties::get($id)); - } - public function edit($id) { + $data = Varieties::init(); $data['variety'] = Varieties::getFull($id); - $data['species'] = Species::getOptions(); - $data['tags_list'] = TagGroups::getTreeTags(); return view('Admin.Botanic.Varieties.edit', $data); } @@ -58,8 +51,10 @@ class VarietyController extends Controller public function getImages(Request $request, $id = false, $can_edit = true) { $id = $id ? $id : $request->input('id'); - $data['images'] = Varieties::getImages($id); - $data['can_edit'] = $can_edit; + $data = [ + 'images' => Varieties::getImages($id), + 'can_edit' => $can_edit, + ]; return view('components.uploader.mini-gallery-items', $data); } @@ -71,9 +66,4 @@ class VarietyController extends Controller return Varieties::deleteImage($id, $index); } - - public function exportExcel() - { - return Varieties::exportExcel(); - } } diff --git a/app/Http/Controllers/Admin/Core/Auth/Controller.php b/app/Http/Controllers/Admin/Core/Auth/Controller.php deleted file mode 100644 index aa1edb29..00000000 --- a/app/Http/Controllers/Admin/Core/Auth/Controller.php +++ /dev/null @@ -1,9 +0,0 @@ -middleware('ability:admin,permissions_crud'); - } - - public function index(PermissionsDataTable $dataTable) - { - $data = \App\Repositories\Config::init(); - - return $dataTable->render('admin.Core.Auth.Permission.index', $data); - } - - public function create() - { - $data = \App\Repositories\Config::init(); - $data['roles'] = Users::getRolesToEdit(); - $data['applications'] = Applications::getOptions(); - $data['application_modules'] = ApplicationModules::getOptions(); - - return view('Admin.Core.Auth.Permission.create', $data); - } - - public function edit(Request $request, $id = false) - { - $id = (int) $id ? $id : $request->input('id'); - $data = \App\Repositories\Config::init(); - $data['permission'] = Permissions::get($id); - $data['roles'] = Users::getRolesToEdit(); - $data['applications'] = Applications::getOptions(); - $data['application_modules'] = ApplicationModules::getOptions(); - - return view('Admin.Core.Auth.Permission.edit', $data); - } - - public function store(Request $request) - { - $data = $request->all(); - unset($data['roles']); - unset($data['_token']); - - /* - $this->validate($request, [ - 'name' => 'required|unique:permissions,name', - 'display_name' => 'required', - 'description' => 'required', - ]); - $data['name'] = Str::slug($data['display_name']); - */ - - Permissions::store($data); - - return redirect()->route('Admin.Core.Auth.Permission.index')->with('growl', [__('permissions.successadd'), 'success']); - } - - public function destroy($id) - { - Permissions::delete($id); - - return response()->json(['error' => 0]); - } -} diff --git a/app/Http/Controllers/Admin/Core/Auth/RoleController.php b/app/Http/Controllers/Admin/Core/Auth/RoleController.php deleted file mode 100644 index c3e729b6..00000000 --- a/app/Http/Controllers/Admin/Core/Auth/RoleController.php +++ /dev/null @@ -1,99 +0,0 @@ -get()->toArray(); - - return $dataTable->render('admin.Core.Auth.Role.index', $data); - } - - public function getTable(Request $request) - { - $model = Role::orderBy('name')->get(); - - return Datatables::of($model)->make(true); - } - - public function create() - { - $data = Config::init(); - - return view('Admin.Core.Auth.Role.create', $data); - } - - public function edit(Request $request, $id = false) - { - $id = $id ? $id : $request->input('id'); - $data = Config::init(); - $data['role'] = Roles::getWithPermissions($id); - $data['modules'] = ApplicationModule::with('permissions')->get()->toArray(); - - return view('Admin.Core.Auth.Role.edit', $data); - } - - public function store(Request $request) - { - Roles::store($request->all()); - - return response()->json(['error' => 0]); - } - - public function destroy(Request $request, $id = false) - { - $id = $id ? $id : $request->input('id'); - Roles::delete($id); - - return response()->json(['error' => 0]); - } - - public function manage(Request $request, $id = false) - { - $data = []; - $id = (int) $id ? $id : $request->input('id'); - $data['role'] = Role::with('permissions')->find($id)->toArray(); - $permissions = Permission::orderBy('app')->orderBy('module')->orderBy('action')->get(); - foreach ($permissions as $permission) { - $data[$permission->app][$permission->module][] = [ - 'action' => $permission->action, - 'description' => $permission->description, - 'id' => $permission->id, - ]; - } - $data['permissions'] = $data; - - return view('Admin.Core.Auth.Role.manage', $data); - } - - public function manage_store(Request $request) - { - $data = $request->all(); - $role = Role::find($data['role_id']); - foreach ($data['permissions'] as $key) { - $permission = Permission::find($key); - $role->attachPermission($permission); - } - - return response()->json(['error' => 0]); - } - - public function toggleActive(Request $request) - { - $data = Roles::toggleActive($request->input('id'), $request->input('active') === 'true' ? 1 : 0); - - return response()->json(['error' => 0]); - } -} diff --git a/app/Http/Controllers/Admin/Core/Auth/TeamController.php b/app/Http/Controllers/Admin/Core/Auth/TeamController.php deleted file mode 100644 index 559a2ff3..00000000 --- a/app/Http/Controllers/Admin/Core/Auth/TeamController.php +++ /dev/null @@ -1,76 +0,0 @@ -middleware('ability:admin,teams_crud'); - } - - public function index() - { - return view('Admin.Core.Auth.Team.list', ['teams' => Team::all()]); - } - - public function create() - { - return view('Admin.Core.Auth.Team.create'); - } - - public function store(Request $request) - { - $input = $request->all(); - $input['name'] = Str::slug($input['display_name']); - $request->replace($input); - - $this->validate( - $request, - [ - 'name' => 'required|unique:teams,name', - 'display_name' => 'required', - 'description' => 'required', - ] - ); - - $team = Team::create($input); - $team->teams()->sync(array_keys($request->input('team', []))); - - return redirect()->route('admin.Teams.edit', $team) - ->with('growl', [__('teams.successadd'), 'success']); - } - - public function edit($id) - { - $team = Team::find($id); - - return view('Admin.Core.Auth.Team.edit', compact('team')); - } - - public function update(Request $request, $id) - { - $this->validate( - $request, - [ - 'display_name' => 'required', - 'description' => 'required', - ] - ); - - $team = Team::find($id); - - return redirect()->route('admin.Teams.edit', $team) - ->with('growl', [__('teams.successmod'), 'success']); - } - - public function destroy($id) - { - Team::destroy($id); - } -} diff --git a/app/Http/Controllers/Admin/Core/Auth/UserController.php b/app/Http/Controllers/Admin/Core/Auth/UserController.php deleted file mode 100644 index 0685bd18..00000000 --- a/app/Http/Controllers/Admin/Core/Auth/UserController.php +++ /dev/null @@ -1,181 +0,0 @@ -render('admin.Core.Auth.User.index', $data); - } - - public function modalCreate() - { - $data = [ - 'roles' => Users::getRolesToEdit(), - ]; - - return view('Admin.Core.Auth.User.modal', $data); - } - - public function modalEdit($id = false) - { - $user = $id ? Users::get($id) : false; - $data['roles'] = Users::getRolesToEdit(); - $data['user'] = $user ? $user->toArray() : []; - $data['user']['roles'] = $user->roles->pluck('id')->toArray(); - - return view('Admin.Core.Auth.User.modal', $data); - } - - public function storeAjax(Request $request) - { - $data = $request->all(); - $ret = Users::store($data); - - return response()->json(['code' => '200']); - } - - public function create() - { - $data = \App\Repositories\Config::init(); - $data['roles'] = Users::getRolesToEdit(); - - return view('Admin.Core.Auth.User.create', $data); - } - - public function store(Request $request) - { - $input = $request->all(); - if ($input['password'] ?? false) { - unset($input['password']); - } - $user = Users::store($input); - - return redirect()->route('admin.Core.Auth.User.index') - ->with('growl', [__('boilerplate::users.successadd'), 'success']); - } - - public function edit($id) - { - $data = Config::init(); - $data['roles'] = Users::getRolesToEdit(); - $data['user'] = Users::get($id); - - return view('Admin.Core.Auth.User.edit', $data); - } - - public function destroy($id) - { - Users::delete($id); - } - - public function firstLogin($token, Request $request) - { - $user = User::where(['remember_token' => $token])->firstOrFail(); - - return view('boilerplate::auth.firstlogin', compact('user', 'token')); - } - - public function firstLoginPost(Request $request) - { - $this->validate($request, [ - 'token' => 'required', - 'password' => 'required|min:8', - 'password_confirmation' => 'required|same:password', - ]); - - $user = User::where(['remember_token' => $request->input('token')])->first(); - - $user->password = bcrypt($request->input('password')); - $user->remember_token = Str::random(32); - $user->last_login = Carbon::now()->toDateTimeString(); - $user->save(); - - Auth::attempt(['email' => $user->email, 'password' => $request->input('password'), 'active' => 1]); - - return redirect()->route('boilerplate.dashboard') - ->with('growl', [__('boilerplate::users.newpassword'), 'success']); - } - - public function profile() - { - $user = Users::get(); - $data['user'] = $user ? $user->toArray() : []; - $data['user']['name'] = $user->name; - $data['user']['avatar'] = Users::getAvatar($user->id); - - return view('Admin.Core.Auth.User.modalProfile', $data); - } - - public function profilePost(Request $request) - { - $this->validate($request, [ - 'avatar' => 'mimes:jpeg,png|max:10000', - 'last_name' => 'required', - 'first_name' => 'required', - 'password_confirmation' => 'same:password', - ]); - - $avatar = $request->file('avatar'); - $user = Auth::user(); - $file = $avatar->isValid(); - - if ($avatar && $file) { - $destinationPath = dirname($user->avatar_path); - if (! is_dir($destinationPath)) { - mkdir($destinationPath, 0766, true); - } - $extension = $avatar->getClientOriginalExtension(); - $fileName = md5($user->id.$user->email).'_tmp.'.$extension; - $avatar->move($destinationPath, $fileName); - - Image::make($destinationPath.DIRECTORY_SEPARATOR.$fileName) - ->fit(100, 100) - ->save($user->avatar_path); - - unlink($destinationPath.DIRECTORY_SEPARATOR.$fileName); - } - - $input = $request->all(); - - if ($input['password'] !== null) { - $input['password'] = bcrypt($input['password']); - $input['remember_token'] = Str::random(32); - } else { - unset($input['password']); - } - - $user->update($input); - - return redirect()->route('boilerplate.user.profile') - ->with('growl', [__('boilerplate::users.profile.successupdate'), 'success']); - } - - public function avatarDelete() - { - $user = Auth::user(); - if (is_file($user->avatar_path)) { - unlink($user->avatar_path); - } - } - - public function toggleActive(Request $request) - { - $data = Users::toggleActive($request->input('id'), $request->input('active') === 'true' ? 1 : 0); - - return response()->json(['error' => 0]); - } -} diff --git a/app/Http/Controllers/Admin/Shop/MerchandiseController.php b/app/Http/Controllers/Admin/Shop/MerchandiseController.php index 69c00db8..3d9644a1 100644 --- a/app/Http/Controllers/Admin/Shop/MerchandiseController.php +++ b/app/Http/Controllers/Admin/Shop/MerchandiseController.php @@ -29,13 +29,6 @@ class MerchandiseController extends Controller return redirect()->route('Admin.Shop.Merchandises.index'); } - public function show($id) - { - $data = Merchandises::get($id); - - return view('Admin.Shop.Merchandises.view', $data); - } - public function edit($id) { $data = Merchandises::init(); @@ -72,9 +65,4 @@ class MerchandiseController extends Controller { return response()->json(['0' => ''] + Merchandises::getOptions()); } - - public function exportExcel() - { - return Merchandises::exportExcel(); - } } diff --git a/app/Http/Controllers/Admin/Shop/PriceListValueController.php b/app/Http/Controllers/Admin/Shop/PriceListValueController.php deleted file mode 100644 index 966b04a7..00000000 --- a/app/Http/Controllers/Admin/Shop/PriceListValueController.php +++ /dev/null @@ -1,75 +0,0 @@ -render('Admin.Shop.PriceListValues.list', $data); - } - - public function create() - { - $data['unities'] = Unities::getOptions(); - $data['taxes_options'] = Taxes::getOptions(); - $data['categories'] = PriceListValueCategories::getOptions(); - - return view('Admin.Shop.PriceListValues.create', $data); - } - - public function edit($id) - { - $data['generic'] = PriceListValues::getFull($id)->toArray(); - $data['packages'] = Packages::getSelectByFamily($data['generic']['category']['article_family_id']); - $data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : []; - $data['taxes_options'] = Taxes::getOptions(); - $data['categories'] = PriceListValueCategories::getOptions(); - - return view('Admin.Shop.PriceListValues.edit', $data); - } - - public function store(Request $request) - { - $ret = PriceListValues::store($request->all()); - - return redirect()->route('Admin.Shop.PriceListValues.index'); - } - - public function show($id) - { - $data = PriceListValues::get($id); - - return view('Admin.Shop.PriceListValues.view', $data); - } - - public function destroy($id) - { - return PriceListValues::destroy($id); - } - - public function getPrice($id) - { - $data['generic'] = PriceListValues::getFull($id); - - return view('Admin.Shop.PriceListValues.partials.table-prices', $data); - } - - public function addPrice($index) - { - $data['index'] = $index; - - return view('Admin.Shop.PriceListValues.partials.row_price', $data); - } -} diff --git a/app/Models/Botanic/Family.php b/app/Models/Botanic/Family.php index b603d2dc..b7959bd8 100644 --- a/app/Models/Botanic/Family.php +++ b/app/Models/Botanic/Family.php @@ -3,6 +3,8 @@ namespace App\Models\Botanic; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use Staudenmeir\EloquentHasManyDeep\HasRelationships; use Wildside\Userstamps\Userstamps; @@ -15,19 +17,19 @@ class Family extends Model protected $table = 'botanic_families'; - public function genres() + public function genres(): HasMany { - return $this->hasMany('App\Models\Botanic\Genre'); + return $this->hasMany(Genre::class); } - public function species() + public function species(): HasManyThrough { - return $this->hasManyThrough('App\Models\Botanic\Specie', 'App\Models\Botanic\Genre'); + return $this->hasManyThrough(Specie::class, Genre::class); } public function varieties() { - return $this->hasManyDeep('App\Models\Botanic\Variety', ['App\Models\Botanic\Genre', 'App\Models\Botanic\Specie']); + return $this->hasManyDeep(Variety::class, [Genre::class, Specie::class]); } public function scopeByName($query, $name) diff --git a/app/Models/Botanic/Genre.php b/app/Models/Botanic/Genre.php index 26c1b21c..8ebd0f30 100644 --- a/app/Models/Botanic/Genre.php +++ b/app/Models/Botanic/Genre.php @@ -3,6 +3,9 @@ namespace App\Models\Botanic; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use Wildside\Userstamps\Userstamps; @@ -14,19 +17,19 @@ class Genre extends Model protected $table = 'botanic_genres'; - public function family() + public function family(): BelongsTo { - return $this->belongsTo('App\Models\Botanic\Family'); + return $this->belongsTo(Family::class); } - public function species() + public function species(): HasMany { - return $this->hasMany('App\Models\Botanic\Specie'); + return $this->hasMany(Specie::class); } - public function varieties() + public function varieties(): HasManyThrough { - return $this->hasManyThrough('App\Models\Botanic\Variety', 'App\Models\Botanic\Specie'); + return $this->hasManyThrough(Variety::class, Specie::class); } public function scopeByName($query, $name) diff --git a/app/Models/Botanic/Specie.php b/app/Models/Botanic/Specie.php index c4cdcb90..ac179508 100644 --- a/app/Models/Botanic/Specie.php +++ b/app/Models/Botanic/Specie.php @@ -6,6 +6,10 @@ use App\Models\Shop\Article; use App\Models\Shop\Tag; use App\Traits\Model\Imageable; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Rinvex\Tags\Traits\Taggable; use Spatie\MediaLibrary\HasMedia; @@ -19,22 +23,22 @@ class Specie extends Model implements HasMedia protected $table = 'botanic_species'; - public function tags() + public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } - public function Genre() + public function Genre(): BelongsTo { return $this->belongsTo(Genre::class); } - public function Varieties() + public function Varieties(): HasMany { return $this->hasMany(Variety::class); } - public function Articles() + public function Articles(): MorphMany { return $this->morphMany(Article::class, 'product'); } diff --git a/app/Models/Botanic/Variety.php b/app/Models/Botanic/Variety.php index 781628f5..1d9d2a88 100644 --- a/app/Models/Botanic/Variety.php +++ b/app/Models/Botanic/Variety.php @@ -6,6 +6,9 @@ use App\Models\Shop\Article; use App\Models\Shop\Tag; use App\Traits\Model\Imageable; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Kirschbaum\PowerJoins\PowerJoins; use Rinvex\Tags\Traits\Taggable; @@ -20,17 +23,17 @@ class Variety extends Model implements HasMedia protected $table = 'botanic_varieties'; - public function Specie() + public function Specie(): BelongsTo { return $this->belongsTo(Specie::class); } - public function Articles() + public function Articles(): MorphMany { return $this->morphMany(Article::class, 'product'); } - public function tags() + public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } diff --git a/app/Models/Core/Auth/Permission.php b/app/Models/Core/Auth/Permission.php index 511450a8..21a73aac 100644 --- a/app/Models/Core/Auth/Permission.php +++ b/app/Models/Core/Auth/Permission.php @@ -9,14 +9,4 @@ class Permission extends parentPermission protected $connection = 'mysql'; protected $guarded = ['id']; - - public function application() - { - return $this->belongsTo(\App\Models\Core\App\Application::class)->withDefault(['name' => '']); - } - - public function application_module() - { - return $this->belongsTo(\App\Models\Core\App\ApplicationModule::class)->withDefault(['name' => '']); - } } diff --git a/app/Models/Core/Auth/PermissionCategory.php b/app/Models/Core/Auth/PermissionCategory.php index e7c7829e..25d54357 100644 --- a/app/Models/Core/Auth/PermissionCategory.php +++ b/app/Models/Core/Auth/PermissionCategory.php @@ -2,7 +2,7 @@ namespace App\Models\Core\Auth; -use Sebastienheyd\Boilerplate\Models\permissionCategory as parentPermissionCategory; +use Sebastienheyd\Boilerplate\Models\PermissionCategory as parentPermissionCategory; class PermissionCategory extends parentPermissionCategory { diff --git a/app/Models/Core/Comment.php b/app/Models/Core/Comment.php index 726035be..3d8ff3c7 100644 --- a/app/Models/Core/Comment.php +++ b/app/Models/Core/Comment.php @@ -5,6 +5,8 @@ namespace App\Models\Core; use App\Traits\Model\HasComments; use Exception; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphTo; class Comment extends Model { @@ -21,12 +23,12 @@ class Comment extends Model return $query->where('is_approved', true); } - public function commentable() + public function commentable(): MorphTo { return $this->morphTo(); } - public function commentator() + public function commentator(): BelongsTo { return $this->belongsTo($this->getAuthModelName(), 'user_id'); } diff --git a/app/Models/Shop/Category.php b/app/Models/Shop/Category.php index d67914d3..e2ac7697 100644 --- a/app/Models/Shop/Category.php +++ b/app/Models/Shop/Category.php @@ -6,6 +6,7 @@ use App\Repositories\Shop\SaleChannels; use Cesargb\Database\Support\CascadeDelete; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Kalnoy\Nestedset\NestedSet; use Rinvex\Categories\Models\Category as parentCategory; @@ -35,7 +36,7 @@ class Category extends parentCategory NestedSet::PARENT_ID, ]; - public function Articles() + public function Articles(): MorphToMany { return $this->morphedByMany(Article::class, 'categorizable'); } diff --git a/app/Models/Shop/Customer.php b/app/Models/Shop/Customer.php index 0f6c632c..9df9096d 100644 --- a/app/Models/Shop/Customer.php +++ b/app/Models/Shop/Customer.php @@ -4,6 +4,8 @@ namespace App\Models\Shop; use App\Notifications\ResetPassword; use App\Notifications\VerifyEmail; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -23,27 +25,27 @@ class Customer extends Authenticatable protected $casts = ['email_verified_at' => 'datetime']; - public function delivery_addresses() + public function delivery_addresses(): HasMany { return $this->addresses()->byDelivery(); } - public function invoice_addresses() + public function invoice_addresses(): HasMany { return $this->addresses()->byInvoicing(); } - public function addresses() + public function addresses(): HasMany { return $this->hasMany(CustomerAddress::class); } - public function customer_deliveries() + public function customer_deliveries(): HasMany { return $this->hasMany(CustomerDelivery::class); } - public function customer_sale_channels() + public function customer_sale_channels(): HasMany { return $this->hasMany(CustomerSaleChannel::class); } @@ -54,17 +56,17 @@ class Customer extends Authenticatable ->whereNull('shop_customer_sale_channels.deleted_at'); } - public function sale_channels() + public function sale_channels(): BelongsToMany { return $this->belongsToMany(SaleChannel::class, CustomerSaleChannel::class)->wherePivotNull('deleted_at'); } - public function invoices() + public function invoices(): HasMany { return $this->hasMany(Invoice::class); } - public function orders() + public function orders(): HasMany { return $this->hasMany(Order::class); } diff --git a/app/Models/Shop/Delivery.php b/app/Models/Shop/Delivery.php index e21a3bf5..d44d7f9d 100644 --- a/app/Models/Shop/Delivery.php +++ b/app/Models/Shop/Delivery.php @@ -3,6 +3,8 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use Staudenmeir\EloquentHasManyDeep\HasRelationships; use Venturecraft\Revisionable\RevisionableTrait; @@ -33,12 +35,12 @@ class Delivery extends Model 'event_date_end', ]; - public function customers() + public function customers(): HasManyThrough { return $this->hasManyThrough(Customer::class, CustomerSaleChannel::class); } - public function sale_channel() + public function sale_channel(): BelongsTo { return $this->belongsTo(SaleChannel::class); } diff --git a/app/Models/Shop/DeliveryTypeCalculation.php b/app/Models/Shop/DeliveryTypeCalculation.php index 0c097b78..bba1b37b 100644 --- a/app/Models/Shop/DeliveryTypeCalculation.php +++ b/app/Models/Shop/DeliveryTypeCalculation.php @@ -3,6 +3,7 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Venturecraft\Revisionable\RevisionableTrait; use Wildside\Userstamps\Userstamps; @@ -19,7 +20,7 @@ class DeliveryTypeCalculation extends Model protected $keepRevisionOf = ['type_id', 'weight', 'price']; - public function delivery_type() + public function delivery_type(): BelongsTo { return $this->belongsTo(DeliveryType::class, 'type_id'); } diff --git a/app/Models/Shop/DistributionChannel.php b/app/Models/Shop/DistributionChannel.php deleted file mode 100644 index 77121372..00000000 --- a/app/Models/Shop/DistributionChannel.php +++ /dev/null @@ -1,20 +0,0 @@ -hasMany(TariffGeneric::class); - } -} diff --git a/app/Models/Shop/Invoice.php b/app/Models/Shop/Invoice.php index 94132b75..70f85dcd 100644 --- a/app/Models/Shop/Invoice.php +++ b/app/Models/Shop/Invoice.php @@ -3,6 +3,8 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use LaracraftTech\LaravelDateScopes\DateScopes; use Venturecraft\Revisionable\RevisionableTrait; @@ -20,22 +22,22 @@ class Invoice extends Model protected $dontKeepRevisionOf = ['updated_by', 'updated_at']; - public function payments() + public function payments(): HasMany { return $this->hasMany(InvoicePayment::class); } - public function order() + public function order(): BelongsTo { return $this->belongsTo(Order::class); } - public function customer() + public function customer(): BelongsTo { return $this->belongsTo(Customer::class, 'customer_id'); } - public function address() + public function address(): BelongsTo { return $this->belongsTo(CustomerAddress::class, 'invoice_address_id'); } diff --git a/app/Models/Shop/InvoicePayment.php b/app/Models/Shop/InvoicePayment.php index e3c111fe..d8acad5c 100644 --- a/app/Models/Shop/InvoicePayment.php +++ b/app/Models/Shop/InvoicePayment.php @@ -3,8 +3,10 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Venturecraft\Revisionable\RevisionableTrait; use Wildside\Userstamps\Userstamps; +use Znck\Eloquent\Relations\BelongsToThrough; class InvoicePayment extends Model { @@ -14,12 +16,12 @@ class InvoicePayment extends Model protected $table = 'shop_invoice_payments'; - public function invoice() + public function invoice(): BelongsTo { return $this->belongsTo(Invoice::class); } - public function order() + public function order(): BelongsToThrough { return $this->belongsToThrough(Order::class, Invoice::class); } diff --git a/app/Models/Shop/Merchandise.php b/app/Models/Shop/Merchandise.php index e13b88ad..c61b8aad 100644 --- a/app/Models/Shop/Merchandise.php +++ b/app/Models/Shop/Merchandise.php @@ -4,6 +4,9 @@ namespace App\Models\Shop; use App\Traits\Model\Imageable; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Kirschbaum\PowerJoins\PowerJoins; use Rinvex\Tags\Traits\Taggable; @@ -28,17 +31,17 @@ class Merchandise extends Model implements HasMedia 'plus', ]; - public function Articles() + public function Articles(): MorphMany { return $this->morphMany(Article::class, 'product'); } - public function Producer() + public function Producer(): BelongsTo { return $this->belongsTo(Producer::class); } - public function tags() + public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } diff --git a/app/Models/Shop/Offer.php b/app/Models/Shop/Offer.php index 8424a3cb..a7cd2ed8 100644 --- a/app/Models/Shop/Offer.php +++ b/app/Models/Shop/Offer.php @@ -4,7 +4,10 @@ namespace App\Models\Shop; use App\Traits\Model\HasComments; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Staudenmeir\EloquentHasManyDeep\HasRelationships; +use Znck\Eloquent\Relations\BelongsToThrough as RelationsBelongsToThrough; use Znck\Eloquent\Traits\BelongsToThrough; class Offer extends Model @@ -15,12 +18,12 @@ class Offer extends Model protected $table = 'shop_offers'; - public function article() + public function article(): BelongsTo { return $this->belongsTo(Article::class); } - public function article_nature() + public function article_nature(): RelationsBelongsToThrough { return $this->belongsToThrough(ArticleNature::class, Article::class, null, '', [ 'App\Models\Shop\Article' => 'article_id', @@ -33,7 +36,7 @@ class Offer extends Model return $this->article->categories(); } - public function price_lists() + public function price_lists(): HasManyThrough { return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id'); } @@ -48,12 +51,12 @@ class Offer extends Model ); } - public function tariff() + public function tariff(): BelongsTo { return $this->belongsTo(Tariff::class); } - public function variation() + public function variation(): BelongsTo { return $this->belongsTo(Variation::class); } diff --git a/app/Models/Shop/Order.php b/app/Models/Shop/Order.php index eafcf2df..45346c9a 100644 --- a/app/Models/Shop/Order.php +++ b/app/Models/Shop/Order.php @@ -3,6 +3,9 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; use LaracraftTech\LaravelDateScopes\DateScopes; use Venturecraft\Revisionable\RevisionableTrait; @@ -19,32 +22,32 @@ class Order extends Model protected $keepRevisionOf = ['customer_address_id', 'delivery_id', 'payment_type', 'status']; - public function customer() + public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } - public function delivery_address() + public function delivery_address(): BelongsTo { return $this->belongsTo(CustomerAddress::class, 'delivery_address_id'); } - public function delivery() + public function delivery(): BelongsTo { return $this->belongsTo(Delivery::class); } - public function detail() + public function detail(): HasMany { return $this->hasMany(OrderDetail::class); } - public function invoice() + public function invoice(): HasOne { return $this->hasOne(Invoice::class); } - public function sale_channel() + public function sale_channel(): BelongsTo { return $this->belongsTo(SaleChannel::class); } diff --git a/app/Models/Shop/OrderDetail.php b/app/Models/Shop/OrderDetail.php index 0b602599..7c0a4d3d 100644 --- a/app/Models/Shop/OrderDetail.php +++ b/app/Models/Shop/OrderDetail.php @@ -3,6 +3,7 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class OrderDetail extends Model { @@ -10,12 +11,12 @@ class OrderDetail extends Model protected $table = 'shop_order_details'; - public function order() + public function order(): BelongsTo { return $this->belongsTo(Order::class); } - public function offer() + public function offer(): BelongsTo { return $this->belongsTo(Offer::class); } diff --git a/app/Models/Shop/Package.php b/app/Models/Shop/Package.php index 6a8e12bb..ffbd3cd0 100644 --- a/app/Models/Shop/Package.php +++ b/app/Models/Shop/Package.php @@ -3,6 +3,9 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; class Package extends Model { @@ -10,22 +13,22 @@ class Package extends Model protected $table = 'shop_packages'; - public function article_family() + public function article_family(): BelongsTo { return $this->belongsTo(ArticleNature::class); } - public function unities() + public function unities(): HasMany { return $this->hasMany(Unity::class); } - public function variations() + public function variations(): HasMany { return $this->hasMany(Variation::class); } - public function offers() + public function offers(): HasManyThrough { return $this->hasManyThrough(Offer::class, Variation::class); } diff --git a/app/Models/Shop/PriceList.php b/app/Models/Shop/PriceList.php index 114e066e..5939f8c7 100644 --- a/app/Models/Shop/PriceList.php +++ b/app/Models/Shop/PriceList.php @@ -4,6 +4,9 @@ namespace App\Models\Shop; use App\Traits\Model\HasComments; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Znck\Eloquent\Traits\BelongsToThrough; class PriceList extends Model @@ -14,22 +17,22 @@ class PriceList extends Model protected $table = 'shop_price_lists'; - public function tariff() + public function tariff(): BelongsTo { return $this->belongsTo(Tariff::class); } - public function offers() + public function offers(): HasManyThrough { return $this->hasManyThrough(Offer::class, Tariff::class, 'id', 'tariff_id', 'id', 'id'); } - public function sale_channel() + public function sale_channel(): BelongsTo { return $this->belongsTo(SaleChannel::class); } - public function price_list_values() + public function price_list_values(): HasMany { return $this->hasMany(PriceListValue::class); } diff --git a/app/Models/Shop/PriceListValue.php b/app/Models/Shop/PriceListValue.php index 5cda60dd..1242c435 100644 --- a/app/Models/Shop/PriceListValue.php +++ b/app/Models/Shop/PriceListValue.php @@ -3,8 +3,10 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Wildside\Userstamps\Userstamps; +use Znck\Eloquent\Relations\BelongsToThrough as RelationsBelongsToThrough; use Znck\Eloquent\Traits\BelongsToThrough; class PriceListValue extends Model @@ -15,12 +17,12 @@ class PriceListValue extends Model protected $table = 'shop_price_list_values'; - public function price_list() + public function price_list(): BelongsTo { return $this->belongsTo(PriceList::class); } - public function tariff() + public function tariff(): RelationsBelongsToThrough { return $this->belongsToThrough( Tariff::class, @@ -34,7 +36,7 @@ class PriceListValue extends Model ); } - public function vat() + public function vat(): BelongsTo { return $this->belongsTo(Tax::class, 'tax_id'); } diff --git a/app/Models/Shop/Producer.php b/app/Models/Shop/Producer.php index 7804fc36..e12891f9 100644 --- a/app/Models/Shop/Producer.php +++ b/app/Models/Shop/Producer.php @@ -4,6 +4,8 @@ namespace App\Models\Shop; use App\Traits\Model\Imageable; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Kirschbaum\PowerJoins\PowerJoins; use Rinvex\Tags\Traits\Taggable; @@ -23,12 +25,12 @@ class Producer extends Model implements HasMedia } - public function Merchandises() + public function Merchandises(): HasMany { return $this->hasMany(Merchandise::class); } - public function tags() + public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); } diff --git a/app/Models/Shop/SaleChannel.php b/app/Models/Shop/SaleChannel.php index 6c27b818..ad92c108 100644 --- a/app/Models/Shop/SaleChannel.php +++ b/app/Models/Shop/SaleChannel.php @@ -3,6 +3,9 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; class SaleChannel extends Model { @@ -10,27 +13,27 @@ class SaleChannel extends Model protected $table = 'shop_sale_channels'; - public function customer_sale_channels() + public function customer_sale_channels(): HasMany { return $this->hasMany(CustomerSaleChannel::class); } - public function customers() + public function customers(): BelongsToMany { return $this->belongsToMany(Customer::class, CustomerSaleChannel::class)->wherePivotNull('deleted_at'); } - public function deliveries() + public function deliveries(): HasMany { return $this->hasMany(Delivery::class); } - public function price_lists() + public function price_lists(): HasMany { return $this->hasMany(PriceList::class); } - public function tariffs() + public function tariffs(): HasManyThrough { return $this->hasManyThrough(Tariff::class, PriceList::class, 'sale_channel_id', 'id', 'id', 'tariff_id'); } diff --git a/app/Models/Shop/Shelve.php b/app/Models/Shop/Shelve.php index 4623584d..9e11ea2c 100644 --- a/app/Models/Shop/Shelve.php +++ b/app/Models/Shop/Shelve.php @@ -3,6 +3,7 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; use Staudenmeir\EloquentHasManyDeep\HasRelationships; class Shelve extends Model @@ -13,18 +14,8 @@ class Shelve extends Model protected $table = 'categories'; - public function articles() + public function articles(): HasMany { return $this->hasMany(Article::class); } - - public function prices() - { - return $this->hasMany(Price::class); - } - - public function packages() - { - return $this->hasMany(Package::class); - } } diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php index 62ebf36a..ef71e485 100644 --- a/app/Models/Shop/Tag.php +++ b/app/Models/Shop/Tag.php @@ -4,6 +4,8 @@ namespace App\Models\Shop; use App\Models\Botanic\Specie; use App\Models\Botanic\Variety; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Rinvex\Tags\Models\Tag as parentTag; class Tag extends parentTag @@ -22,42 +24,42 @@ class Tag extends parentTag ]; // TODO - public function offers() + public function offers(): MorphToMany { return $this->articles(); } - public function articles() + public function articles(): MorphToMany { return $this->morphedByMany(Article::class, 'taggable'); } - public function categories() + public function categories(): MorphToMany { return $this->morphedByMany(Category::class, 'taggable'); } - public function tag_group() + public function tag_group(): BelongsTo { return $this->belongsTo(TagGroup::class); } - public function shelves() + public function shelves(): MorphToMany { return $this->morphedByMany(Shelve::class, 'taggable'); } - public function species() + public function species(): MorphToMany { return $this->morphedByMany(Specie::class, 'taggable'); } - public function varieties() + public function varieties(): MorphToMany { return $this->morphedByMany(Variety::class, 'taggable'); } - public function merchandises() + public function merchandises(): MorphToMany { return $this->morphedByMany(Merchandise::class, 'taggable'); } diff --git a/app/Models/Shop/TagGroup.php b/app/Models/Shop/TagGroup.php index b62ee6d3..60935152 100644 --- a/app/Models/Shop/TagGroup.php +++ b/app/Models/Shop/TagGroup.php @@ -4,6 +4,8 @@ namespace App\Models\Shop; use Dyrynda\Database\Support\CascadeSoftDeletes; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; class TagGroup extends Model @@ -16,12 +18,12 @@ class TagGroup extends Model protected $cascadeDeletes = ['tags']; - public function tags() + public function tags(): HasMany { return $this->hasMany(Tag::class); } - public function article_family() + public function article_family(): BelongsTo { return $this->belongsTo(ArticleNature::class); } diff --git a/app/Models/Shop/Tariff.php b/app/Models/Shop/Tariff.php index 7764c984..7a0ac343 100644 --- a/app/Models/Shop/Tariff.php +++ b/app/Models/Shop/Tariff.php @@ -4,6 +4,9 @@ namespace App\Models\Shop; use App\Traits\Model\HasComments; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Kirschbaum\PowerJoins\PowerJoins; use Staudenmeir\EloquentHasManyDeep\HasRelationships; @@ -15,32 +18,32 @@ class Tariff extends Model protected $table = 'shop_tariffs'; - public function offers() + public function offers(): HasMany { return $this->hasMany(Offer::class); } - public function sale_channel() + public function sale_channel(): BelongsTo { return $this->belongsTo(SaleChannel::class); } - public function sale_channels() + public function sale_channels(): HasManyThrough { return $this->HasManyThrough(SaleChannel::class, PriceList::class, 'id', 'id', 'id', 'sale_channel_id'); } - public function tariff_unity() + public function tariff_unity(): BelongsTo { return $this->belongsTo(TariffUnity::class); } - public function price_lists() + public function price_lists(): HasMany { return $this->hasMany(PriceList::class); } - public function price_list_values() + public function price_list_values(): HasManyThrough { return $this->hasManyThrough(PriceListValue::class, PriceList::class); } diff --git a/app/Models/Shop/Variation.php b/app/Models/Shop/Variation.php index a1be1576..f3ff54de 100644 --- a/app/Models/Shop/Variation.php +++ b/app/Models/Shop/Variation.php @@ -4,6 +4,8 @@ namespace App\Models\Shop; use App\Traits\Model\HasComments; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class Variation extends Model { @@ -13,17 +15,17 @@ class Variation extends Model protected $table = 'shop_variations'; - public function package() + public function package(): BelongsTo { return $this->belongsTo(Package::class); } - public function unity() + public function unity(): BelongsTo { return $this->belongsTo(Unity::class); } - public function offers() + public function offers(): HasMany { return $this->hasMany(Offer::class); } diff --git a/app/Repositories/Botanic/Families.php b/app/Repositories/Botanic/Families.php index 706c6491..6ba0148d 100644 --- a/app/Repositories/Botanic/Families.php +++ b/app/Repositories/Botanic/Families.php @@ -2,20 +2,13 @@ namespace App\Repositories\Botanic; -use App\Exports\Botanic\FamiliesExport; use App\Models\Botanic\Family; use App\Traits\Model\Basic; -use Maatwebsite\Excel\Facades\Excel; class Families { use Basic; - public static function exportExcel() - { - return Excel::download(new FamiliesExport(), 'families.xlsx'); - } - public static function getModel() { return Family::query(); diff --git a/app/Repositories/Botanic/Genres.php b/app/Repositories/Botanic/Genres.php index 127e9654..09bfd7ce 100644 --- a/app/Repositories/Botanic/Genres.php +++ b/app/Repositories/Botanic/Genres.php @@ -2,20 +2,20 @@ namespace App\Repositories\Botanic; -use App\Exports\Botanic\GenresExport; use App\Models\Botanic\Genre; use App\Traits\Model\Basic; -use Maatwebsite\Excel\Facades\Excel; class Genres { use Basic; - public static function exportExcel() + public static function init() { - return Excel::download(new GenresExport(), 'genres.xlsx'); + return [ + 'families' => Families::getOptions(), + ]; } - + public static function getModel() { return Genre::query(); diff --git a/app/Repositories/Botanic/Species.php b/app/Repositories/Botanic/Species.php index c11ea1e1..e4fe1c4c 100644 --- a/app/Repositories/Botanic/Species.php +++ b/app/Repositories/Botanic/Species.php @@ -2,17 +2,24 @@ namespace App\Repositories\Botanic; -use App\Exports\Botanic\SpeciesExport; use App\Models\Botanic\Specie; use App\Repositories\Core\Tag; +use App\Repositories\Shop\TagGroups; use App\Traits\Model\Basic; use App\Traits\Repository\Imageable; -use Maatwebsite\Excel\Facades\Excel; class Species { use Basic, Imageable; + public static function init() + { + return [ + 'genres' => Genres::getOptions(), + 'tags_list' => TagGroups::getTreeTags(), + ]; + + } public static function getDescription($id) { return self::get($id)->description ?? ''; @@ -62,11 +69,6 @@ class Species return Tag::storeTags($specie, $tags); } - public static function exportExcel() - { - return Excel::download(new SpeciesExport(), 'species.xlsx'); - } - public static function getModel() { return Specie::query(); diff --git a/app/Repositories/Botanic/Varieties.php b/app/Repositories/Botanic/Varieties.php index c8a58c2b..8994e894 100644 --- a/app/Repositories/Botanic/Varieties.php +++ b/app/Repositories/Botanic/Varieties.php @@ -2,17 +2,23 @@ namespace App\Repositories\Botanic; -use App\Exports\Botanic\VarietiesExport; use App\Models\Botanic\Variety; use App\Repositories\Core\Tag; use App\Traits\Model\Basic; use App\Traits\Repository\Imageable; -use Maatwebsite\Excel\Facades\Excel; class Varieties { use Basic, Imageable; + public static function init() + { + return [ + 'species' => Species::getOptions(), + 'tags_list' => TagGroups::getTreeTags(), + ]; + } + public static function getOptionsWithSpecie() { $varieties = Variety::with('specie')->get(); @@ -72,11 +78,6 @@ class Varieties return Tag::storeTags($variety, $tags); } - public static function exportExcel() - { - return Excel::download(new VarietiesExport(), 'varieties.xlsx'); - } - public static function getModel() { return Variety::query(); diff --git a/app/Traits/Model/Imageable.php b/app/Traits/Model/Imageable.php index 84a31fbc..36ba942f 100644 --- a/app/Traits/Model/Imageable.php +++ b/app/Traits/Model/Imageable.php @@ -2,6 +2,8 @@ namespace App\Traits\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; @@ -10,12 +12,12 @@ trait Imageable { use InteractsWithMedia; - public function images() + public function images(): HasMany { return $this->hasMany(Media::class, 'model_id')->where('model_type', get_class($this)); } - public function image() + public function image(): HasOne { return $this->hasOne(Media::class, 'model_id')->where('model_type', get_class($this))->latest(); } diff --git a/resources/views/Admin/Core/App/Application/create.blade.php b/resources/views/Admin/Core/App/Application/create.blade.php deleted file mode 100644 index a1df72b6..00000000 --- a/resources/views/Admin/Core/App/Application/create.blade.php +++ /dev/null @@ -1,21 +0,0 @@ -@extends('layout.index', [ - 'title' => __('countries.title'), - 'subtitle' => __('countries.add'), - 'breadcrumb' => [ - __('Country.title') => 'Admin.Country.index' - ] -]) - -@section('content') - - {{ Form::open(['route' => 'Admin.Country.store', 'id' => 'country-form', 'autocomplete' => 'off']) }} - - @include('components.save') - - @component('components.card') - @include('admin.Country.form') - @endcomponent - - - -@endsection diff --git a/resources/views/Admin/Core/App/Application/dashboard.blade.php b/resources/views/Admin/Core/App/Application/dashboard.blade.php deleted file mode 100644 index add932b1..00000000 --- a/resources/views/Admin/Core/App/Application/dashboard.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -@extends('layout.index', [ - 'title' => __('DueDiligence.distributors.title'), - 'subtitle' => __('DueDiligence.distributors.list'), - 'breadcrumb' => [__('DueDiligence.distributors.title')] -]) - -@section('content') - - @include('apps.DueDiligence.admin.Distributor.partials.dashboard') - -@endsection - diff --git a/resources/views/Admin/Core/App/Application/edit.blade.php b/resources/views/Admin/Core/App/Application/edit.blade.php deleted file mode 100644 index 36f051f5..00000000 --- a/resources/views/Admin/Core/App/Application/edit.blade.php +++ /dev/null @@ -1,23 +0,0 @@ -@extends('layout.index', [ - 'title' => __('countries.title'), - 'subtitle' => __('countries.edit'), - 'breadcrumb' => [ - __('countries.title') => 'Admin.Country.index' - ] -]) - -@section('content') - - {{ Form::open(['route' => 'Admin.Country.store', 'id' => 'country-form', 'autocomplete' => 'off']) }} - - - - @include('components.save') - - @component('components.card') - @include('admin.Country.form') - @endcomponent - - - -@endsection diff --git a/resources/views/Admin/Core/App/Application/exports/excel.blade.php b/resources/views/Admin/Core/App/Application/exports/excel.blade.php deleted file mode 100644 index c2ad0bcd..00000000 --- a/resources/views/Admin/Core/App/Application/exports/excel.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - @include('apps.DueDiligence.admin.Distributor.partials.table', ['logo2' => public_path('/storage/partner/fundglobam/images/logo.png') ]) - \ No newline at end of file diff --git a/resources/views/Admin/Core/App/Application/exports/print.blade.php b/resources/views/Admin/Core/App/Application/exports/print.blade.php deleted file mode 100644 index fc1c0793..00000000 --- a/resources/views/Admin/Core/App/Application/exports/print.blade.php +++ /dev/null @@ -1,18 +0,0 @@ - - -
- - - - - - - @include('apps.DueDiligence.admin.Distributor.partials.table', ['logo' => '/storage/partner/fundglobam/images/logo.png']) - - - - - \ No newline at end of file diff --git a/resources/views/Admin/Core/App/Application/form.blade.php b/resources/views/Admin/Core/App/Application/form.blade.php deleted file mode 100644 index 4c2f6d1e..00000000 --- a/resources/views/Admin/Core/App/Application/form.blade.php +++ /dev/null @@ -1,31 +0,0 @@ -@include('load.form.select2') - -| {{ __('module') }} | -{{ __('actions') }} | -
|---|