diff --git a/app/Console/Commands/addTagGroup.php b/app/Console/Commands/addTagGroup.php
index 77ae2c2b..a0145a8b 100644
--- a/app/Console/Commands/addTagGroup.php
+++ b/app/Console/Commands/addTagGroup.php
@@ -6,7 +6,7 @@ use App\Models\Shop\Tag;
use App\Repositories\Shop\TagGroups;
use Illuminate\Console\Command;
-class addTagGroup extends Command
+class AddTagGroup extends Command
{
protected $signature = 'addTagGroup';
diff --git a/app/Console/Commands/untranslateShelves.php b/app/Console/Commands/untranslateShelves.php
index ae721685..943349e0 100644
--- a/app/Console/Commands/untranslateShelves.php
+++ b/app/Console/Commands/untranslateShelves.php
@@ -5,7 +5,7 @@ namespace App\Console\Commands;
use App\Models\Shop\Category;
use Illuminate\Console\Command;
-class untranslateShelves extends Command
+class UntranslateShelves extends Command
{
protected $signature = 'untranslateShelves';
diff --git a/app/Console/Commands/untranslateTags.php b/app/Console/Commands/untranslateTags.php
index 347013a0..d5c58d92 100644
--- a/app/Console/Commands/untranslateTags.php
+++ b/app/Console/Commands/untranslateTags.php
@@ -5,7 +5,7 @@ namespace App\Console\Commands;
use App\Models\Shop\Tag;
use Illuminate\Console\Command;
-class untranslateTags extends Command
+class UntranslateTags extends Command
{
protected $signature = 'untranslateTags';
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 89fce550..7d190b50 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -7,31 +7,13 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
- /**
- * The Artisan commands provided by your application.
- *
- * @var array
- */
protected $commands = [
- //
];
- /**
- * Define the application's command schedule.
- *
- * @return void
- */
protected function schedule(Schedule $schedule)
{
- // $schedule->command('inspire')
- // ->hourly();
}
- /**
- * Register the commands for the application.
- *
- * @return void
- */
protected function commands()
{
$this->load(__DIR__.'/Commands');
diff --git a/app/Datatables/ParentDataTable.php b/app/Datatables/ParentDataTable.php
index 9d6452c8..02e52e66 100644
--- a/app/Datatables/ParentDataTable.php
+++ b/app/Datatables/ParentDataTable.php
@@ -30,12 +30,6 @@ class ParentDataTable extends DataTable
public $stateSave = true;
- /**
- * Build DataTable class.
- *
- * @param mixed $query Results from query() method.
- * @return \Yajra\DataTables\DataTableAbstract
- */
public function dataTable($query)
{
return $this->modifier(datatables()->eloquent($query));
@@ -46,12 +40,6 @@ class ParentDataTable extends DataTable
return $this->addButtons($datatables->setRowId('{{$id}}'));
}
- /**
- * Add buttons DataTable class.
- *
- * @param mixed $query Results from query() method.
- * @return \Yajra\DataTables\DataTableAbstract
- */
public function addButtons($datatables)
{
return $datatables->addColumn('action', $this->getHtmlButtons());
@@ -59,12 +47,7 @@ class ParentDataTable extends DataTable
public function getHtmlButtons()
{
- $buttons = '';
- $buttons .= self::getButtonEdit();
- $buttons .= self::getButtonDel();
-
- return $buttons;
- // return view('components.datatables.buttons.row_action');
+ return self::getButtonEdit().self::getButtonDel();
}
public function getButtonEdit()
@@ -95,35 +78,23 @@ class ParentDataTable extends DataTable
public static function isFilteredByField($field)
{
- return (request()->has('filters.'.$field)) ? request()->input('filters.'.$field) : (request()->has($field) ? request()->input($field) : false);
+ if (request()->has('filters.'.$field)) {
+ return request()->input('filters.'.$field);
+ }
+
+ return request()->has($field) ? request()->input($field) : false;
}
- /**
- * Get query source of dataTable.
- *
- * @param \App\Family $model
- * @return \Illuminate\Database\Eloquent\Builder
- */
public function buildQuery($model)
{
return $model->newQuery();
}
- /**
- * Optional method if you want to use html builder.
- *
- * @return \Yajra\DataTables\Html\Builder
- */
public function html()
{
return $this->buildHtml(strtolower($this->model_name).'-table');
}
- /**
- * Optional method if you want to use html builder.
- *
- * @return \Yajra\DataTables\Html\Builder
- */
public function buildHtml($table_id = false, $selector = false)
{
$table_id = $table_id ? $table_id : strtolower($this->model_name).'-table';
@@ -135,7 +106,7 @@ class ParentDataTable extends DataTable
->columns($this->getColumns())
->ajax([
'data' => 'function(d) { d.filters = $("'.$selector.'").serializeJSON(); }',
- 'url' => isset($this->url) ? $this->url : '',
+ 'url' => $this->url ?? '',
])
->dom($this->getDom())
->orderBy($this->sortedColumn, $this->sortedOrder)
@@ -145,7 +116,6 @@ class ParentDataTable extends DataTable
public function getButtons()
{
return [
- // Button::make('export'),
Button::make('print'),
Button::make('colvis'),
Button::make('columnsToggle'),
@@ -174,12 +144,7 @@ class ParentDataTable extends DataTable
public function getDom()
{
- $dom = '';
- // $dom .= $this->getDatatablesHeaderDefault();
- $dom .= 'rt';
- $dom .= $this->getDatatablesFooterDefault();
-
- return $dom;
+ return 'rt'.$this->getDatatablesFooterDefault();
}
public function getDatatablesHeader()
@@ -189,23 +154,7 @@ class ParentDataTable extends DataTable
public function getDatatablesHeaderDefault()
{
- // return "
";
- /*
-
- $dom = 't<"row datatable-pager light"<"col-md-12"'
- . '<"datatable-more-export-buttons filter-buttons pull-left">'
- . '<"datatable-more-export-favorites-buttons filter-buttons pull-left">'
- . '<"datatable-more-export-basket-buttons filter-buttons pull-left">'
- . '<"datatable-download-buttons filter-buttons pull-left">'
- . '>>'
- . '<"dt-toolbar-footer"<"col"i><"col pull-right datatable-pager light nopadding-right"p>>';
-
- */
-
- $dom = "<'row dt-toolbar-header'<'col-lg-4'l><'col-lg-4'B><'col-lg-4 text-right add'f>>";
-
- return $dom;
- // return 't<"row datatable-pager light"<"col-md-12"<"datatable-more-export-buttons filter-buttons pull-left"><"datatable-more-export-favorites-buttons filter-buttons pull-left"><"datatable-more-export-basket-buttons filter-buttons pull-left"><"datatable-download-buttons filter-buttons pull-left">>><"dt-toolbar-footer"<"col-md-6"i><"col-md-6 pull-right datatable-pager light nopadding-right"p>>';
+ return "<'row dt-toolbar-header'<'col-lg-4'l><'col-lg-4'B><'col-lg-4 text-right add'f>>";
}
public function getDatatablesFooterDefault()
@@ -213,19 +162,11 @@ class ParentDataTable extends DataTable
return "<'row pt-3 dt-toolbar-footer'<'col-md-6'i><'col-md-6'p>>";
}
- /**
- * Get filename for export.
- */
protected function filename(): string
{
return self::buildFilename($this->model_name);
}
- /**
- * Get filename for export.
- *
- * @return string
- */
protected function buildFilename($name)
{
return $name.'_'.date('YmdHis');
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index d140581e..97a8c611 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -7,47 +7,19 @@ use Throwable;
class Handler extends ExceptionHandler
{
- /**
- * A list of the exception types that are not reported.
- *
- * @var array
- */
protected $dontReport = [
- //
];
- /**
- * A list of the inputs that are never flashed for validation exceptions.
- *
- * @var array
- */
protected $dontFlash = [
'password',
'password_confirmation',
];
- /**
- * Report or log an exception.
- *
- * @param \Exception $exception
- * @return void
- *
- * @throws \Exception
- */
public function report(Throwable $exception)
{
parent::report($exception);
}
- /**
- * Render an exception into an HTTP response.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Exception $exception
- * @return \Symfony\Component\HttpFoundation\Response
- *
- * @throws \Exception
- */
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
diff --git a/app/Http/Controllers/Admin/Core/App/ApplicationController.php b/app/Http/Controllers/Admin/Core/App/ApplicationController.php
deleted file mode 100644
index 2a23b66a..00000000
--- a/app/Http/Controllers/Admin/Core/App/ApplicationController.php
+++ /dev/null
@@ -1,48 +0,0 @@
-render('admin.Core.App.Application.index', $data);
- }
-
- public function edit(Request $request, $id = false)
- {
- $id = $id ? $id : $request->input('id');
- $data = \App\Repositories\Config::init();
- $data = Applications::get($id);
-
- return view('Admin.Core.App.Application.edit', $data);
- }
-
- public function store(Request $request)
- {
- Applications::store($request->all());
-
- return response()->json(['error' => 0]);
- }
-
- public function destroy(Request $request, $id = false)
- {
- $id = $id ? $id : $request->input('id');
- Applications::destroy($id);
-
- return response()->json(['error' => 0]);
- }
-
- public function toggleActive(Request $request)
- {
- $data = Applications::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
-
- return response()->json(['error' => 0]);
- }
-}
diff --git a/app/Http/Controllers/Admin/Core/App/ApplicationModuleController.php b/app/Http/Controllers/Admin/Core/App/ApplicationModuleController.php
deleted file mode 100644
index ddfa68ba..00000000
--- a/app/Http/Controllers/Admin/Core/App/ApplicationModuleController.php
+++ /dev/null
@@ -1,59 +0,0 @@
-render('admin.Core.App.ApplicationModule.index', $data);
- }
-
- public function create()
- {
- $data = \App\Repositories\Config::init();
- $data['applications'] = Applications::getOptions();
-
- return view('Admin.Core.App.ApplicationModule.create', $data);
- }
-
- public function edit(Request $request, $id = false)
- {
- $id = $id ? $id : $request->input('id');
- $data = \App\Repositories\Config::init();
- $data = ApplicationModules::get($id)->toArray();
- $data['applications'] = Applications::getOptions();
-
- return view('Admin.Core.App.ApplicationModule.edit', $data);
- }
-
- public function store(Request $request)
- {
- ApplicationModules::store($request->all());
-
- return redirect()->route('admin.Core.App.ApplicationModule.index')
- ->with('growl', [__('admin.successadd'), 'success']);
- }
-
- public function destroy(Request $request, $id = false)
- {
- $id = $id ? $id : $request->input('id');
- ApplicationModules::destroy($id);
-
- return response()->json(['error' => 0]);
- }
-
- public function toggleActive(Request $request)
- {
- $data = ApplicationModules::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
-
- return response()->json(['error' => 0]);
- }
-}
diff --git a/app/Http/Controllers/Admin/Core/App/Controller.php b/app/Http/Controllers/Admin/Core/App/Controller.php
deleted file mode 100644
index 5bf43289..00000000
--- a/app/Http/Controllers/Admin/Core/App/Controller.php
+++ /dev/null
@@ -1,9 +0,0 @@
-get()->toArray();
return $dataTable->render('admin.Core.Auth.Role.index', $data);
@@ -29,7 +30,7 @@ class RoleController extends Controller
public function create()
{
- $data = \App\Repositories\Config::init();
+ $data = Config::init();
return view('Admin.Core.Auth.Role.create', $data);
}
@@ -37,7 +38,7 @@ class RoleController extends Controller
public function edit(Request $request, $id = false)
{
$id = $id ? $id : $request->input('id');
- $data = \App\Repositories\Config::init();
+ $data = Config::init();
$data['role'] = Roles::getWithPermissions($id);
$data['modules'] = ApplicationModule::with('permissions')->get()->toArray();
@@ -72,9 +73,6 @@ class RoleController extends Controller
'id' => $permission->id,
];
}
- // Debug::fdump($data);
- // Debug::fdump($permissions);
- // exit;
$data['permissions'] = $data;
return view('Admin.Core.Auth.Role.manage', $data);
@@ -94,7 +92,7 @@ class RoleController extends Controller
public function toggleActive(Request $request)
{
- $data = Roles::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
+ $data = Roles::toggle_active($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
index 0fed7793..559a2ff3 100644
--- a/app/Http/Controllers/Admin/Core/Auth/TeamController.php
+++ b/app/Http/Controllers/Admin/Core/Auth/TeamController.php
@@ -31,7 +31,8 @@ class TeamController extends Controller
$request->replace($input);
$this->validate(
- $request, [
+ $request,
+ [
'name' => 'required|unique:teams,name',
'display_name' => 'required',
'description' => 'required',
@@ -55,7 +56,8 @@ class TeamController extends Controller
public function update(Request $request, $id)
{
$this->validate(
- $request, [
+ $request,
+ [
'display_name' => 'required',
'description' => 'required',
]
diff --git a/app/Http/Controllers/Admin/Core/Auth/UserController.php b/app/Http/Controllers/Admin/Core/Auth/UserController.php
index b82eb6ed..0e58268e 100644
--- a/app/Http/Controllers/Admin/Core/Auth/UserController.php
+++ b/app/Http/Controllers/Admin/Core/Auth/UserController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin\Core\Auth;
use App\Datatables\Admin\Core\Auth\UsersDataTable;
use App\Models\Core\Auth\User;
+use App\Repositories\Config;
use App\Repositories\Core\Auth\Users;
use Carbon\Carbon;
use Illuminate\Http\Request;
@@ -15,14 +16,16 @@ class UserController extends Controller
{
public function index(UsersDataTable $dataTable)
{
- $data = \App\Repositories\Config::init();
+ $data = Config::init();
return $dataTable->render('admin.Core.Auth.User.index', $data);
}
public function modalCreate()
{
- $data['roles'] = Users::getRolesToEdit();
+ $data = [
+ 'roles' => Users::getRolesToEdit(),
+ ];
return view('Admin.Core.Auth.User.modal', $data);
}
@@ -55,13 +58,6 @@ class UserController extends Controller
public function store(Request $request)
{
- /*
- $this->validate($request, [
- 'last_name' => 'required',
- 'first_name' => 'required',
- 'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL',
- ]);
- */
$input = $request->all();
if (empty($input['password'])) {
unset($input['password']);
@@ -74,7 +70,7 @@ class UserController extends Controller
public function edit($id)
{
- $data = \App\Repositories\Config::init();
+ $data = Config::init();
$data['roles'] = Users::getRolesToEdit();
$data['user'] = Users::get($id);
@@ -95,13 +91,11 @@ class UserController extends Controller
public function firstLoginPost(Request $request)
{
- $this->validate(
- $request, [
- 'token' => 'required',
- 'password' => 'required|min:8',
- 'password_confirmation' => 'required|same:password',
- ]
- );
+ $this->validate($request, [
+ 'token' => 'required',
+ 'password' => 'required|min:8',
+ 'password_confirmation' => 'required|same:password',
+ ]);
$user = User::where(['remember_token' => $request->input('token')])->first();
@@ -128,19 +122,18 @@ class UserController extends Controller
public function profilePost(Request $request)
{
- $this->validate(
- $request, [
- 'avatar' => 'mimes:jpeg,png|max:10000',
- 'last_name' => 'required',
- 'first_name' => 'required',
- 'password_confirmation' => 'same:password',
- ]
- );
+ $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 = $avatar->isValid()) {
+ if ($avatar && $file) {
$destinationPath = dirname($user->avatar_path);
if (! is_dir($destinationPath)) {
mkdir($destinationPath, 0766, true);
@@ -181,7 +174,7 @@ class UserController extends Controller
public function toggleActive(Request $request)
{
- $data = Users::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
+ $data = Users::toggle_active($request->input('id'), ($request->input('active') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Admin/Shop/ArticleController.php b/app/Http/Controllers/Admin/Shop/ArticleController.php
index e3b579ed..bb50e79b 100644
--- a/app/Http/Controllers/Admin/Shop/ArticleController.php
+++ b/app/Http/Controllers/Admin/Shop/ArticleController.php
@@ -67,24 +67,32 @@ class ArticleController extends Controller
return Articles::destroy($id);
}
- public function getProductDescription($product_id, $model)
+ public function getProductDescription($productId, $model)
{
- $data['article']['inherited'] = Articles::getInheritedByProduct($product_id, base64_decode($model));
+ $data = [
+ 'article' => [
+ 'inherited' => Articles::getInheritedByProduct($productId, base64_decode($model)),
+ ],
+ ];
return view('Admin.Shop.Articles.partials.product.description', $data);
}
- public function getProductTags($product_id, $model)
+ public function getProductTags($productId, $model)
{
- $data = Articles::getInheritedByProduct($product_id, base64_decode($model));
+ $data = Articles::getInheritedByProduct($productId, base64_decode($model));
return view('Admin.Shop.Articles.partials.product.tags', $data);
}
- public function getProductImages($product_id, $model)
+ public function getProductImages($productId)
{
- $data['article']['product_id'] = $product_id;
- $data['no_popup'] = false;
+ $data = [
+ 'article' => [
+ 'product_id' => $productId,
+ ],
+ 'no_popup' => false,
+ ];
return view('Admin.Shop.Articles.partials.product.images', $data);
}
@@ -92,7 +100,9 @@ class ArticleController extends Controller
public function getImages(Request $request, $id = false)
{
$id = $id ? $id : $request->input('id');
- $data['images'] = Articles::getImages($id);
+ $data = [
+ 'images' => Articles::getImages($id),
+ ];
return view('components.uploader.mini-gallery-items', $data);
}
@@ -107,14 +117,14 @@ class ArticleController extends Controller
public function toggleVisible(Request $request)
{
- $data = Articles::toggleVisible($request->input('id'), ($request->input('visible') == 'true') ? 1 : 0);
+ $data = Articles::toggleVisible($request->input('id'), ($request->input('visible') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
public function toggleHomepage(Request $request)
{
- $data = Articles::toggleHomepage($request->input('id'), ($request->input('homepage') == 'true') ? 1 : 0);
+ $data = Articles::toggleHomepage($request->input('id'), ($request->input('homepage') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Admin/Shop/CategoryController.php b/app/Http/Controllers/Admin/Shop/CategoryController.php
index 7f7f9032..de070cf8 100644
--- a/app/Http/Controllers/Admin/Shop/CategoryController.php
+++ b/app/Http/Controllers/Admin/Shop/CategoryController.php
@@ -80,14 +80,14 @@ class CategoryController extends Controller
public function toggleVisible(Request $request)
{
- $data = Categories::toggle_visible($request->input('id'), ($request->input('visible') == 'true') ? 1 : 0);
+ $data = Categories::toggleVisible($request->input('id'), ($request->input('visible') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
public function toggleHomepage(Request $request)
{
- $data = Categories::toggleHomepage($request->input('id'), ($request->input('homepage') == 'true') ? 1 : 0);
+ $data = Categories::toggleHomepage($request->input('id'), ($request->input('homepage') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Admin/Shop/DeliveryController.php b/app/Http/Controllers/Admin/Shop/DeliveryController.php
index 1c4c3c01..66c9c8c9 100644
--- a/app/Http/Controllers/Admin/Shop/DeliveryController.php
+++ b/app/Http/Controllers/Admin/Shop/DeliveryController.php
@@ -53,7 +53,7 @@ class DeliveryController extends Controller
public function toggleActive(Request $request)
{
- $data = Deliveries::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
+ $data = Deliveries::toggle_active($request->input('id'), ($request->input('active') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Admin/Shop/InvoiceController.php b/app/Http/Controllers/Admin/Shop/InvoiceController.php
index b24ed766..3aae0231 100644
--- a/app/Http/Controllers/Admin/Shop/InvoiceController.php
+++ b/app/Http/Controllers/Admin/Shop/InvoiceController.php
@@ -38,11 +38,6 @@ class InvoiceController extends Controller
{
$data = Invoices::init();
$data['invoice'] = Invoices::getFull($id)->toArray();
- /*
- $model = new InvoicePaymentsDataTable();
- $data['invoice_payments'] = $model->html();
- */
- // dump($data);
return view('Admin.Shop.Invoices.edit', $data);
}
diff --git a/app/Http/Controllers/Admin/Shop/InvoiceItemController.php b/app/Http/Controllers/Admin/Shop/InvoiceItemController.php
deleted file mode 100644
index 357f145d..00000000
--- a/app/Http/Controllers/Admin/Shop/InvoiceItemController.php
+++ /dev/null
@@ -1,80 +0,0 @@
-input('id'), ($request->input('status_id') == 'true') ? 1 : 0);
+ $data = Offers::toggle_active($request->input('id'), ($request->input('status_id') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Admin/Shop/PackageController.php b/app/Http/Controllers/Admin/Shop/PackageController.php
index 1b15b316..ab4ab911 100644
--- a/app/Http/Controllers/Admin/Shop/PackageController.php
+++ b/app/Http/Controllers/Admin/Shop/PackageController.php
@@ -53,11 +53,6 @@ class PackageController extends Controller
return view('Admin.Shop.Packages.edit', $data);
}
- public function update(Request $request)
- {
- //
- }
-
public function destroy($id)
{
return Packages::destroy($id);
diff --git a/app/Http/Controllers/Admin/Shop/TagController.php b/app/Http/Controllers/Admin/Shop/TagController.php
index f9b0cc05..a6830da8 100644
--- a/app/Http/Controllers/Admin/Shop/TagController.php
+++ b/app/Http/Controllers/Admin/Shop/TagController.php
@@ -45,11 +45,6 @@ class TagController extends Controller
return view('Admin.Shop.Tags.edit', $data);
}
- public function update(Request $request)
- {
- //
- }
-
public function destroy($id)
{
return Tags::destroy($id);
diff --git a/app/Http/Controllers/Admin/Shop/TagGroupController.php b/app/Http/Controllers/Admin/Shop/TagGroupController.php
index 4b3adf97..3fabf9e0 100644
--- a/app/Http/Controllers/Admin/Shop/TagGroupController.php
+++ b/app/Http/Controllers/Admin/Shop/TagGroupController.php
@@ -51,7 +51,7 @@ class TagGroupController extends Controller
public function toggleVisible(Request $request)
{
- $data = TagGroups::toggleVisible($request->input('id'), ($request->input('visible') == 'true') ? 1 : 0);
+ $data = TagGroups::toggleVisible($request->input('id'), ($request->input('visible') === 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}
diff --git a/app/Http/Controllers/Shop/ArticleController.php b/app/Http/Controllers/Shop/ArticleController.php
index 2991c47c..4a1cc8c1 100644
--- a/app/Http/Controllers/Shop/ArticleController.php
+++ b/app/Http/Controllers/Shop/ArticleController.php
@@ -4,18 +4,14 @@ namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\Articles;
-use App\Repositories\Shop\Categories;
class ArticleController extends Controller
{
public function show($id)
{
$data['article'] = Articles::getArticleToSell($id);
- // $data['breadcrumb'] = Categories::getAncestorsByCategory($category_id);
$data['offers2'] = Articles::getSiblings($id)->toArray();
- // dump($data);
- // exit;
return view('Shop.Articles.show', $data);
}
}
diff --git a/app/Http/Controllers/Shop/Auth/ForgotPasswordController.php b/app/Http/Controllers/Shop/Auth/ForgotPasswordController.php
index 2c645084..a7c73994 100644
--- a/app/Http/Controllers/Shop/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Shop/Auth/ForgotPasswordController.php
@@ -11,11 +11,6 @@ class ForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
- protected function guard()
- {
- return Auth::guard('customer');
- }
-
public function broker()
{
return Password::broker('customers');
@@ -25,4 +20,9 @@ class ForgotPasswordController extends Controller
{
return view('Shop.auth.passwords.email');
}
+
+ protected function guard()
+ {
+ return Auth::guard('customer');
+ }
}
diff --git a/app/Http/Controllers/Shop/Auth/LoginController.php b/app/Http/Controllers/Shop/Auth/LoginController.php
index 54f22c22..ab1f342c 100644
--- a/app/Http/Controllers/Shop/Auth/LoginController.php
+++ b/app/Http/Controllers/Shop/Auth/LoginController.php
@@ -18,11 +18,6 @@ class LoginController extends Controller
// $this->middleware('guest')->except('logout');
}
- protected function guard()
- {
- return Auth::guard('customer');
- }
-
public function showLoginForm()
{
return view('Shop.auth.login');
@@ -38,10 +33,12 @@ class LoginController extends Controller
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
$request->session()->regenerate();
- return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back();
+ return (back()->getTargetUrl() === route('Shop.login')) ? redirect()->intended(route('home')) : back();
}
- return back()->withErrors(['msg' => 'Identifiant ou mot de passe incorrect'])->withInput($request->only('email', 'remember'));
+ return back()->withErrors([
+ 'msg' => 'Identifiant ou mot de passe incorrect',
+ ])->withInput($request->only('email', 'remember'));
}
public function logout(Request $request)
@@ -57,4 +54,10 @@ class LoginController extends Controller
{
return 'email';
}
+
+ protected function guard()
+ {
+ return Auth::guard('customer');
+ }
+
}
diff --git a/app/Http/Controllers/Shop/Auth/RegisterController.php b/app/Http/Controllers/Shop/Auth/RegisterController.php
index 99fc4046..16a98a31 100644
--- a/app/Http/Controllers/Shop/Auth/RegisterController.php
+++ b/app/Http/Controllers/Shop/Auth/RegisterController.php
@@ -5,29 +5,15 @@ namespace App\Http\Controllers\Shop\Auth;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\CustomerAddresses;
use App\Repositories\Shop\Customers;
-use Illuminate\Auth\Events\Registered;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
-use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RegisterController extends Controller
{
- // use RegistersUsers;
-
protected $redirectTo;
- protected function guard()
- {
- return Auth::guard('customer');
- }
-
- protected function redirectTo()
- {
- return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
- }
-
public function showRegistrationForm()
{
return view('Shop.auth.register');
@@ -35,16 +21,12 @@ class RegisterController extends Controller
public function register(Request $request)
{
- dump('ici');
- exit;
- // event(new Registered($user = $this->create($request->all())));
$user = $this->create($request->all());
- dump($user);
- exit;
$this->guard()->login($user);
+ $response = $this->registered($request, $user);
- if ($response = $this->registered($request, $user)) {
+ if ($response) {
return $response;
}
@@ -53,14 +35,6 @@ class RegisterController extends Controller
: redirect($this->redirectPath());
}
- protected function create(array $data)
- {
- $user = Customers::create($data);
- CustomerAddresses::add($user->id, $data);
-
- return $user;
- }
-
public function emailVerify()
{
if (Auth::user()->hasVerifiedEmail()) {
@@ -83,4 +57,23 @@ class RegisterController extends Controller
return back()->with('message', 'Verification link sent!');
}
+
+ protected function create(array $data)
+ {
+ $user = Customers::create($data);
+ CustomerAddresses::add($user->id, $data);
+
+ return $user;
+ }
+
+ protected function guard()
+ {
+ return Auth::guard('customer');
+ }
+
+ protected function redirectTo()
+ {
+ return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
+ }
+
}
diff --git a/app/Http/Controllers/Shop/Auth/ResetPasswordController.php b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php
index 4268d9b9..6ddc8212 100644
--- a/app/Http/Controllers/Shop/Auth/ResetPasswordController.php
+++ b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php
@@ -14,6 +14,11 @@ class ResetPasswordController extends Controller
protected $redirectTo = '/';
+ public function broker()
+ {
+ return Password::broker('customers');
+ }
+
public function showResetForm(Request $request, $token = null)
{
return view('Shop.auth.passwords.reset')->with([
@@ -31,11 +36,6 @@ class ResetPasswordController extends Controller
];
}
- public function broker()
- {
- return Password::broker('customers');
- }
-
protected function guard()
{
return Auth::guard('customer');
diff --git a/app/Http/Controllers/Shop/InvoiceController.php b/app/Http/Controllers/Shop/InvoiceController.php
index 05ed873e..c43db8ff 100644
--- a/app/Http/Controllers/Shop/InvoiceController.php
+++ b/app/Http/Controllers/Shop/InvoiceController.php
@@ -25,11 +25,7 @@ class InvoiceController extends Controller
\Debugbar::disable();
$data['invoice'] = Invoices::getByUUID($uuid);
$filename = 'invoice-'.$uuid.'.pdf';
- $html = view('Shop.Invoices.pdf', $data)->toHtml();
- // $html = 'Hello world!
';
- // return PDF::convertHTML($html);
- // return view('Shop.Invoices.pdf', $data);
return PDF::view('Shop.Invoices.pdf', $data, $filename);
}
}
diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php
index fa71eb13..c45c2bc6 100644
--- a/app/Http/Controllers/Shop/OrderController.php
+++ b/app/Http/Controllers/Shop/OrderController.php
@@ -31,7 +31,9 @@ class OrderController extends Controller
public function pdf($uuid)
{
- $data['order'] = Orders::getByUUID($uuid);
+ $data = [
+ 'order' => Orders::getByUUID($uuid),
+ ];
return view('Shop.Orders.pdf', $data);
}
@@ -45,15 +47,14 @@ class OrderController extends Controller
$data = [
'customer' => $customer ? $customer->toArray() : false,
'basket' => Baskets::getBasketTotal(),
- // 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'deliveries' => $deliveries ? $deliveries->toArray() : [],
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
];
return view('Shop.Orders.order', $data);
- } else {
- return redirect()->route('home');
}
+
+ return redirect()->route('home');
}
public function store(Request $request)
@@ -64,17 +65,13 @@ class OrderController extends Controller
$data['basket'] = Baskets::getBasketSummary($data['sale_channel_id'], $data['delivery_type_id'] ?? false);
$order = Orders::saveOrder($data);
if ($order) {
- if ($data['payment_type'] == '1') {
+ if ($data['payment_type'] === '1') {
return Paybox::makeAuthorizationRequest($order);
- } else {
- return redirect()->route('Shop.Orders.confirmed');
}
- if ($ret) {
- OrderMails::sendOrderConfirmed($order->id);
- }
- } else {
- return view('Shop.Orders.order');
+ OrderMails::sendOrderConfirmed($order->id);
+ return redirect()->route('Shop.Orders.confirmed');
}
+ return view('Shop.Orders.order');
}
public function confirmed()
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index e6fa3f2b..3c129b85 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -6,12 +6,6 @@ use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
- /**
- * Get the path the user should be redirected to when they are not authenticated.
- *
- * @param \Illuminate\Http\Request $request
- * @return string|null
- */
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php
index 35b9824b..c9d40e36 100644
--- a/app/Http/Middleware/CheckForMaintenanceMode.php
+++ b/app/Http/Middleware/CheckForMaintenanceMode.php
@@ -6,12 +6,6 @@ use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
- /**
- * The URIs that should be reachable while maintenance mode is enabled.
- *
- * @var array
- */
protected $except = [
- //
];
}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
index 033136ad..86f1e82e 100644
--- a/app/Http/Middleware/EncryptCookies.php
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -6,12 +6,6 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
- /**
- * The names of the cookies that should not be encrypted.
- *
- * @var array
- */
protected $except = [
- //
];
}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 324a166b..313a7068 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -6,19 +6,8 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
- /**
- * Indicates whether the XSRF-TOKEN cookie should be set on the response.
- *
- * @var bool
- */
protected $addHttpCookie = true;
- /**
- * The URIs that should be excluded from CSRF verification.
- *
- * @var array
- */
protected $except = [
- //
];
}
diff --git a/app/Mail/Acheminement.php b/app/Mail/Acheminement.php
index cf811210..09d5c4c7 100644
--- a/app/Mail/Acheminement.php
+++ b/app/Mail/Acheminement.php
@@ -13,8 +13,6 @@ class Acheminement extends TemplateMailable
{
use MailCustomers, Queueable, SerializesModels;
- protected static $templateModelClass = MailTemplate::class;
-
public $email;
public $nom;
@@ -43,6 +41,8 @@ class Acheminement extends TemplateMailable
public $mode_livraison;
+ protected static $templateModelClass = MailTemplate::class;
+
public function __construct($order)
{
$this->prenom = $order->customer->first_name;
diff --git a/app/Mail/Bienvenue.php b/app/Mail/Bienvenue.php
index 68df7abf..463bf97a 100644
--- a/app/Mail/Bienvenue.php
+++ b/app/Mail/Bienvenue.php
@@ -12,8 +12,6 @@ class Bienvenue extends TemplateMailable
{
use MailCustomers, Queueable, SerializesModels;
- protected static $templateModelClass = MailTemplate::class;
-
public $email;
public $nom;
@@ -24,6 +22,8 @@ class Bienvenue extends TemplateMailable
public $subject;
+ protected static $templateModelClass = MailTemplate::class;
+
public function __construct($user, $subject = '')
{
$this->prenom = $user->first_name;
diff --git a/app/Mail/ConfirmationCommande.php b/app/Mail/ConfirmationCommande.php
index bfad8a51..8295f15e 100644
--- a/app/Mail/ConfirmationCommande.php
+++ b/app/Mail/ConfirmationCommande.php
@@ -12,8 +12,6 @@ class ConfirmationCommande extends TemplateMailable
{
use MailCustomers, Queueable, SerializesModels;
- protected static $templateModelClass = MailTemplate::class;
-
public $email;
public $nom;
@@ -40,6 +38,8 @@ class ConfirmationCommande extends TemplateMailable
public $livraison_ville;
+ protected static $templateModelClass = MailTemplate::class;
+
public function __construct($order)
{
$this->prenom = $order->customer->first_name;
diff --git a/app/Mail/Preparation.php b/app/Mail/Preparation.php
index 2baf9e8b..8b6671af 100644
--- a/app/Mail/Preparation.php
+++ b/app/Mail/Preparation.php
@@ -12,8 +12,6 @@ class Preparation extends TemplateMailable
{
use MailCustomers, Queueable, SerializesModels;
- protected static $templateModelClass = MailTemplate::class;
-
public $email;
public $nom;
@@ -24,6 +22,8 @@ class Preparation extends TemplateMailable
public $subject;
+ protected static $templateModelClass = MailTemplate::class;
+
public function __construct($order)
{
$this->prenom = $order->customer->first_name;
diff --git a/app/Models/Core/App/Application.php b/app/Models/Core/App/Application.php
deleted file mode 100644
index 67b2c8eb..00000000
--- a/app/Models/Core/App/Application.php
+++ /dev/null
@@ -1,44 +0,0 @@
-hasMany(\App\Models\Core\App\ApplicationPage::class);
- }
-
- public function modules()
- {
- return $this->hasMany(\App\Models\Core\App\ApplicationModule::class);
- }
-
- public function scopeActive($query)
- {
- return $query->where('active', 1);
- }
-
- public function scopeVisible($query)
- {
- return $query->where('visible', 1);
- }
-
- public function scopeBySlug($query, $slug)
- {
- return $query->where('slug', $slug);
- }
-
- public function scopeByOrder($query)
- {
- return $query->sortBy('order');
- }
-}
diff --git a/app/Models/Core/App/ApplicationClient.php b/app/Models/Core/App/ApplicationClient.php
deleted file mode 100644
index 5f76363d..00000000
--- a/app/Models/Core/App/ApplicationClient.php
+++ /dev/null
@@ -1,48 +0,0 @@
-belongsTo(\App\Models\Core\App\Application::class);
- }
-
- public function client()
- {
- return $this->belongsTo('App\Models\Partner\Client');
- }
-
- public function scopeActive($query)
- {
- return $query->where('active', 1);
- }
-
- public function scopeByApplication($query, $id)
- {
- return $query->where('application_id', $id);
- }
-
- public function scopeByClient($query, $id)
- {
- return $query->where('client_id', $id);
- }
-
- public function scopeBySlug($query, $slug)
- {
- return $query->whereHas('application', function ($query) use ($slug) {
- $query->bySlug($slug);
- });
- }
-}
diff --git a/app/Models/Core/App/ApplicationModule.php b/app/Models/Core/App/ApplicationModule.php
deleted file mode 100644
index ff2e9aec..00000000
--- a/app/Models/Core/App/ApplicationModule.php
+++ /dev/null
@@ -1,41 +0,0 @@
-belongsTo(\App\Models\Core\App\Application::class);
- }
-
- public function permissions()
- {
- return $this->hasMany(\App\Models\Core\Auth\Permission::class);
- }
-
- public function scopeActive($query)
- {
- return $query->where('active', 1);
- }
-
- public function scopeByApplication($query, $id)
- {
- return $query->where('application_id', $id);
- }
-
- public function scopeBySlug($query, $slug)
- {
- return $query->where('slug', $slug);
- }
-}
diff --git a/app/Models/Core/App/ApplicationPage.php b/app/Models/Core/App/ApplicationPage.php
deleted file mode 100644
index 3fd25077..00000000
--- a/app/Models/Core/App/ApplicationPage.php
+++ /dev/null
@@ -1,34 +0,0 @@
-belongsTo(\App\Models\Core\App\Application::class);
- }
-
- public function scopeActive($query)
- {
- return $query->where('active', 1);
- }
-
- public function scopeByApplication($query, $application_id)
- {
- return $query->where('application_id', $application_id);
- }
-
- public function scopeBySlug($query, $slug)
- {
- return $query->where('slug', $slug);
- }
-}
diff --git a/app/Models/Core/Auth/Team.php b/app/Models/Core/Auth/Team.php
index 726d6902..9b2bf12d 100644
--- a/app/Models/Core/Auth/Team.php
+++ b/app/Models/Core/Auth/Team.php
@@ -9,13 +9,13 @@ class Team extends LaratrustTeam
{
use SoftDeletes;
- protected $connection = 'mysql';
-
public $timestamps = false;
+ protected $connection = 'mysql';
+
public function users()
{
- return $this->hasMany(\App\Models\Core\Auth\User::class);
+ return $this->hasMany(User::class);
}
public function scopeActive($query)
diff --git a/app/Models/Core/Auth/UserClient.php b/app/Models/Core/Auth/UserClient.php
deleted file mode 100644
index 01831e26..00000000
--- a/app/Models/Core/Auth/UserClient.php
+++ /dev/null
@@ -1,34 +0,0 @@
-belongsTo('App\Models\Partner\Client');
- }
-
- public function user()
- {
- return $this->belongsTo('App\Models\User');
- }
-
- public function scopeByClient($query, $id)
- {
- return $query->where('client_id', $id);
- }
-
- public function scopeByUser($query, $id)
- {
- return $query->where('user_id', $id);
- }
-}
diff --git a/app/Models/Core/Auth/UserStatus.php b/app/Models/Core/Auth/UserStatus.php
index 88d757a1..6c7813f7 100644
--- a/app/Models/Core/Auth/UserStatus.php
+++ b/app/Models/Core/Auth/UserStatus.php
@@ -6,14 +6,14 @@ use Illuminate\Database\Eloquent\Model;
class UserStatus extends Model
{
+ public $timestamps = false;
+
protected $connection = 'mysql';
protected $guarded = [];
protected $table = 'user_statuses';
- public $timestamps = false;
-
public function scopeByName($query, $name)
{
return $query->where('name', $name);
diff --git a/app/Models/Core/Auth/UserStatusTeam.php b/app/Models/Core/Auth/UserStatusTeam.php
index bd43c8d0..0a7424b0 100644
--- a/app/Models/Core/Auth/UserStatusTeam.php
+++ b/app/Models/Core/Auth/UserStatusTeam.php
@@ -6,22 +6,22 @@ use Illuminate\Database\Eloquent\Model;
class UserStatusTeam extends Model
{
+ public $timestamps = false;
+
protected $connection = 'mysql';
protected $guarded = [];
protected $table = 'user_status_teams';
- public $timestamps = false;
-
public function user_status()
{
- return $this->belongsTo(\App\Models\Core\Auth\UserStatus::class);
+ return $this->belongsTo(UserStatus::class);
}
public function team()
{
- return $this->belongsTo(\App\Models\Core\Auth\Team::class);
+ return $this->belongsTo(Team::class);
}
public function scopeByUserStatus($query, $id)
diff --git a/app/Models/Shop/Category.php b/app/Models/Shop/Category.php
index e60d8a04..d67914d3 100644
--- a/app/Models/Shop/Category.php
+++ b/app/Models/Shop/Category.php
@@ -16,12 +16,12 @@ class Category extends parentCategory
{
use CascadeDelete, SoftDeletes, Taggable, Userstamps;
+ public $translatable = [];
+
protected $guarded = ['id'];
protected $table = 'categories';
- public $translatable = [];
-
protected $cascadeDeleteMorph = ['Articles'];
protected $fillable = [
diff --git a/app/Models/Shop/Customer.php b/app/Models/Shop/Customer.php
index bb5c18f4..0f6c632c 100644
--- a/app/Models/Shop/Customer.php
+++ b/app/Models/Shop/Customer.php
@@ -50,9 +50,7 @@ class Customer extends Authenticatable
public function deliveries()
{
- return $this->hasManyDeepFromRelations(
- $this->sale_channels(),
- (new SaleChannel())->deliveries())
+ return $this->hasManyDeepFromRelations($this->sale_channels(), (new SaleChannel())->deliveries())
->whereNull('shop_customer_sale_channels.deleted_at');
}
diff --git a/app/Models/Shop/PriceListValue.php b/app/Models/Shop/PriceListValue.php
index f38fd7a1..5cda60dd 100644
--- a/app/Models/Shop/PriceListValue.php
+++ b/app/Models/Shop/PriceListValue.php
@@ -22,7 +22,11 @@ class PriceListValue extends Model
public function tariff()
{
- return $this->belongsToThrough(Tariff::class, PriceList::class, null, '',
+ return $this->belongsToThrough(
+ Tariff::class,
+ PriceList::class,
+ null,
+ '',
[
'App\Models\Shop\Tariff' => 'tariff_id',
'App\Models\Shop\PriceList' => 'price_list_id',
diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php
index cb8d647b..62ebf36a 100644
--- a/app/Models/Shop/Tag.php
+++ b/app/Models/Shop/Tag.php
@@ -8,6 +8,8 @@ use Rinvex\Tags\Models\Tag as parentTag;
class Tag extends parentTag
{
+ public $translatable = [];
+
protected $guarded = ['id'];
protected $fillable = [
@@ -19,8 +21,6 @@ class Tag extends parentTag
'tag_group_id',
];
- public $translatable = [];
-
// TODO
public function offers()
{
@@ -69,9 +69,11 @@ class Tag extends parentTag
public function scopeWithCountArticlesByCategory($query, $category_id)
{
- return $query->withCount(['articles' => function ($query) use ($category_id) {
- $query->byCategoryParent($category_id);
- }]);
+ return $query->withCount([
+ 'articles' => function ($query) use ($category_id) {
+ $query->byCategoryParent($category_id);
+ },
+ ]);
}
public function scopeById($query, $id)
diff --git a/app/Notifications/NewUser.php b/app/Notifications/NewUser.php
index d9a7c172..35653d42 100644
--- a/app/Notifications/NewUser.php
+++ b/app/Notifications/NewUser.php
@@ -5,31 +5,20 @@ namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
+use Illuminate\Support\Facades\Auth;
class NewUser extends Notification
{
use Queueable;
- /**
- * Get the notification's delivery channels.
- *
- * @param mixed $notifiable
- * @return string[]
- */
public function via($notifiable)
{
return ['mail'];
}
- /**
- * Get the mail representation of the notification.
- *
- * @param mixed $notifiable
- * @return \Illuminate\Notifications\Messages\MailMessage
- */
public function toMail($notifiable)
{
- $currentUser = \Auth::user();
+ $currentUser = Auth::user();
return (new MailMessage())
->markdown('boilerplate::notifications.email')
@@ -48,16 +37,9 @@ class NewUser extends Notification
->line(__('boilerplate::notifications.newuser.outro'));
}
- /**
- * Get the array representation of the notification.
- *
- * @param mixed $notifiable
- * @return array
- */
public function toArray($notifiable)
{
return [
- //
];
}
}
diff --git a/app/Notifications/ResetPassword.php b/app/Notifications/ResetPassword.php
index c0c02824..6b8c7f47 100644
--- a/app/Notifications/ResetPassword.php
+++ b/app/Notifications/ResetPassword.php
@@ -6,12 +6,6 @@ use Illuminate\Notifications\Messages\MailMessage;
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
{
- /**
- * Get the mail representation of the notification.
- *
- * @param mixed $notifiable
- * @return \Illuminate\Notifications\Messages\MailMessage
- */
public function toMail($notifiable)
{
return (new MailMessage())
diff --git a/app/Notifications/VerifyEmail.php b/app/Notifications/VerifyEmail.php
index bbf1edf3..4629aacd 100644
--- a/app/Notifications/VerifyEmail.php
+++ b/app/Notifications/VerifyEmail.php
@@ -26,15 +26,9 @@ class VerifyEmail extends BaseEmail
);
}
- /**
- * Get the verify email notification mail message for the given URL.
- *
- * @param string $url
- * @return \Illuminate\Notifications\Messages\MailMessage
- */
protected function buildMailMessage($url)
{
- return (new MailMessage)
+ return (new MailMessage())
->markdown('boilerplate::notifications.email')
->subject(__('Verify Email Address'))
->line(__('Please click the button below to verify your email address.'))
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index de1e9d20..1e0cfbe7 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -9,21 +9,6 @@ use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- //
- }
-
- /**
- * Bootstrap any application services.
- *
- * @return void
- */
public function boot()
{
Schema::defaultStringLength(191);
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index b14e5898..e1ecf3c1 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -6,24 +6,12 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
class AuthServiceProvider extends ServiceProvider
{
- /**
- * The policy mappings for the application.
- *
- * @var array
- */
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
- /**
- * Register any authentication / authorization services.
- *
- * @return void
- */
public function boot()
{
$this->registerPolicies();
-
- //
}
}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 723a290d..5b281049 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -5,30 +5,12 @@ namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
-use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
- /**
- * The event listener mappings for the application.
- *
- * @var array
- */
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
-
- /**
- * Register any events for your application.
- *
- * @return void
- */
- public function boot()
- {
- parent::boot();
-
- //
- }
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 540d17b4..8b06cbd4 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -7,55 +7,16 @@ use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
- /**
- * This namespace is applied to your controller routes.
- *
- * In addition, it is set as the URL generator's root namespace.
- *
- * @var string
- */
- protected $namespace = 'App\Http\Controllers';
-
- /**
- * The path to the "home" route for your application.
- *
- * @var string
- */
public const HOME = '/home';
- /**
- * Define your route model bindings, pattern filters, etc.
- *
- * @return void
- */
- public function boot()
- {
- //
+ protected $namespace = 'App\Http\Controllers';
- parent::boot();
- }
-
- /**
- * Define the routes for the application.
- *
- * @return void
- */
public function map()
{
$this->mapApiRoutes();
-
$this->mapWebRoutes();
-
- //
}
- /**
- * Define the "web" routes for the application.
- *
- * These routes all receive session state, CSRF protection, etc.
- *
- * @return void
- */
protected function mapWebRoutes()
{
Route::middleware('web')
@@ -63,13 +24,6 @@ class RouteServiceProvider extends ServiceProvider
->group(base_path('routes/web.php'));
}
- /**
- * Define the "api" routes for the application.
- *
- * These routes are typically stateless.
- *
- * @return void
- */
protected function mapApiRoutes()
{
Route::prefix('api')
diff --git a/app/Repositories/Botanic/Families.php b/app/Repositories/Botanic/Families.php
index 79bddce7..706c6491 100644
--- a/app/Repositories/Botanic/Families.php
+++ b/app/Repositories/Botanic/Families.php
@@ -4,62 +4,20 @@ namespace App\Repositories\Botanic;
use App\Exports\Botanic\FamiliesExport;
use App\Models\Botanic\Family;
+use App\Traits\Model\Basic;
use Maatwebsite\Excel\Facades\Excel;
-use Yajra\DataTables\DataTables;
class Families
{
- public static function getDatatable()
- {
- $model = Family::orderBy('name');
-
- return Datatables::of($model)->make(true);
- }
-
- public static function getOptions()
- {
- return Family::get()->SortBy('name')->pluck('name', 'id')->toArray();
- }
-
- public static function getAll()
- {
- return Family::orderBy('name', 'asc')->get();
- }
-
- public static function get($id)
- {
- return Family::findOrFail($id);
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
- $item = $id ? self::update($data, $id) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return Family::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return Family::destroy($id);
- }
+ use Basic;
public static function exportExcel()
{
- return Excel::download(new FamiliesExport, 'families.xlsx');
+ 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 8d7c91f8..127e9654 100644
--- a/app/Repositories/Botanic/Genres.php
+++ b/app/Repositories/Botanic/Genres.php
@@ -4,53 +4,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
{
- public static function getOptions()
- {
- return Genre::get()->SortBy('name')->pluck('name', 'id')->toArray();
- }
-
- public static function getAll()
- {
- return Genre::orderBy('name', 'asc')->get();
- }
-
- public static function get($id)
- {
- return Genre::find($id);
- }
-
- public static function store($data)
- {
- $item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return Genre::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $model = self::get($id);
- $model->update($data);
-
- return $model;
- }
-
- public static function destroy($id)
- {
- return Genre::destroy($id);
- }
+ use Basic;
public static function exportExcel()
{
- return Excel::download(new GenresExport, 'genres.xlsx');
+ return Excel::download(new GenresExport(), 'genres.xlsx');
+ }
+
+ public static function getModel()
+ {
+ return Genre::query();
}
}
diff --git a/app/Repositories/Botanic/Species.php b/app/Repositories/Botanic/Species.php
index eb346ef6..c11ea1e1 100644
--- a/app/Repositories/Botanic/Species.php
+++ b/app/Repositories/Botanic/Species.php
@@ -5,22 +5,13 @@ namespace App\Repositories\Botanic;
use App\Exports\Botanic\SpeciesExport;
use App\Models\Botanic\Specie;
use App\Repositories\Core\Tag;
+use App\Traits\Model\Basic;
use App\Traits\Repository\Imageable;
use Maatwebsite\Excel\Facades\Excel;
class Species
{
- use Imageable;
-
- public static function getOptions()
- {
- return Specie::get()->SortBy('name')->pluck('name', 'id')->toArray();
- }
-
- public static function getAll()
- {
- return Specie::orderBy('name', 'asc')->get();
- }
+ use Basic, Imageable;
public static function getDescription($id)
{
@@ -66,30 +57,6 @@ class Species
return $specie;
}
- public static function store($data)
- {
- return ($data['id'] ?? false) ? self::update($data) : self::create($data);
- }
-
- public static function create($data)
- {
- return Specie::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $model = self::get($id);
- $ret = $model->update($data);
-
- return $model;
- }
-
- public static function destroy($id)
- {
- return Specie::destroy($id);
- }
-
public static function storeTags($specie, $tags)
{
return Tag::storeTags($specie, $tags);
@@ -97,6 +64,11 @@ class Species
public static function exportExcel()
{
- return Excel::download(new SpeciesExport, 'species.xlsx');
+ 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 cc4ea39e..c8a58c2b 100644
--- a/app/Repositories/Botanic/Varieties.php
+++ b/app/Repositories/Botanic/Varieties.php
@@ -5,17 +5,13 @@ 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 Imageable;
-
- public static function getOptions()
- {
- return Variety::orderBy('name')->get()->pluck('name', 'id')->toArray();
- }
+ use Basic, Imageable;
public static function getOptionsWithSpecie()
{
@@ -29,11 +25,6 @@ class Varieties
return $data;
}
- public static function getAll()
- {
- return Variety::orderBy('name', 'asc')->get();
- }
-
public static function getDescription($id)
{
return self::get($id)->description;
@@ -65,8 +56,8 @@ class Varieties
public static function storeFull($data)
{
- $images = isset($data['images']) ? $data['images'] : false;
- $tags = isset($data['tags']) ? $data['tags'] : false;
+ $images = $data['images'] ?? false;
+ $tags = $data['tags'] ?? false;
unset($data['images']);
unset($data['tags']);
$variety = self::store($data);
@@ -76,30 +67,6 @@ class Varieties
return $variety;
}
- public static function store($data)
- {
- return ($data['id'] ?? false) ? self::update($data) : self::create($data);
- }
-
- public static function create($data)
- {
- return Variety::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $variety = self::get($id);
- $ret = $variety->update($data);
-
- return $variety;
- }
-
- public static function destroy($id)
- {
- return Variety::destroy($id);
- }
-
public static function storeTags($variety, $tags)
{
return Tag::storeTags($variety, $tags);
@@ -107,6 +74,11 @@ class Varieties
public static function exportExcel()
{
- return Excel::download(new VarietiesExport, 'varieties.xlsx');
+ return Excel::download(new VarietiesExport(), 'varieties.xlsx');
+ }
+
+ public static function getModel()
+ {
+ return Variety::query();
}
}
diff --git a/app/Repositories/Cities.php b/app/Repositories/Cities.php
index f679adea..40121a6c 100644
--- a/app/Repositories/Cities.php
+++ b/app/Repositories/Cities.php
@@ -9,20 +9,23 @@ class Cities
{
public static function getCitiesByName($query)
{
- return City::select('id', DB::raw("concat(nom,' (',code_postal,')') as text"))->where('nom', 'LIKE', "$query%")->orderBy('nom', 'ASC')->take(30)->get();
+ return City::select('id', DB::raw("concat(nom,' (',code_postal,')') as text"))
+ ->where('nom', 'LIKE', "{$query}%")
+ ->orderBy('nom', 'ASC')->take(30)->get();
}
public static function getCitiesByCP($query)
{
- return City::select('id', DB::raw("concat(nom,' (',code_postal,')') as text"))->where('code_postal', 'LIKE', "%q$guery%")->orderBy('nom', 'ASC')->take(30)->get();
+ return City::select('id', DB::raw("concat(nom,' (',code_postal,')') as text"))
+ ->where('code_postal', 'LIKE', "%{$query}%")
+ ->orderBy('nom', 'ASC')->take(30)->get();
}
public static function getCPByCity($id)
{
$ville = self::get($id);
- $codes = explode('-', $ville->code_postal);
- return $codes;
+ return explode('-', $ville->code_postal);
}
public static function getNomByCity($id)
@@ -39,24 +42,15 @@ class Cities
public static function getCoords($adresse)
{
- // dd(app('geocoder')->geocode('Los Angeles, CA')->get());
- // dd(app('geocoder')->geocode('5 boulevard du Port, Amiens, France')->get());
- // dump($adresse);
$geocode = app('geocoder')->geocode($adresse)->get();
- // dump($geocode);
if (! count($geocode)) {
return false;
}
- // dump($geocode);
$res = $geocode[0]->getCoordinates()->toArray();
- // dump($res);
$latitude = $res[0];
$longitude = $res[1];
- // dump($latitude);
- // dump($longitude);
return ['latitude' => $latitude, 'longitude' => $longitude];
-
}
public static function getCoordsByCity($id)
diff --git a/app/Repositories/Core/App/ApplicationClients.php b/app/Repositories/Core/App/ApplicationClients.php
deleted file mode 100644
index ff6a7d34..00000000
--- a/app/Repositories/Core/App/ApplicationClients.php
+++ /dev/null
@@ -1,93 +0,0 @@
-count();
- }
-
- public static function associateApplications($client_id, $applications)
- {
- $client_name = Clients::getName($client_id);
- foreach ($applications as $key => $application_id) {
- $application = Applications::get($application_id);
- if ($application) {
- self::associateApplication($client_id, $application_id);
- }
- }
-
- return true;
- }
-
- public static function associateApplication($client_id, $application_id)
- {
- return ApplicationClient::create(['client_id' => $client_id, 'application_id' => $application_id, 'active' => true]);
- }
-
- public static function dissociateApplications($client_id, $applications)
- {
- $client_name = Clients::getName($client_id);
- foreach ($applications as $key => $application_id) {
- self::dissociateApplication($client_id, $application_id);
- }
-
- return true;
- }
-
- public static function dissociateApplication($client_id, $application_id)
- {
- return ApplicationClient::byClient($client_id)->byApplication($application_id)->delete();
- }
-
- public static function getByClient($id)
- {
- return ApplicationClient::byClient($id)->get()->toArray();
- }
-
- public static function getByApplication($id)
- {
- return ApplicationClient::byApplication($id)->get()->toArray();
- }
-
- public static function getClientsByApplication($id)
- {
- return ApplicationClient::byApplication($id)->get()->pluck('client_id')->toArray();
- }
-
- public static function getApplicationsByClient($id)
- {
- return ApplicationClient::byClient($id)->get()->pluck('application_id')->toArray();
- }
-
- public static function isActiveByName($name)
- {
- return (! Clients::isClient()) ? true : ApplicationClient::bySlug($name)->byClient(Clients::getId())->first()->active ?? false;
- }
-}
diff --git a/app/Repositories/Core/App/ApplicationModules.php b/app/Repositories/Core/App/ApplicationModules.php
deleted file mode 100644
index a5cada87..00000000
--- a/app/Repositories/Core/App/ApplicationModules.php
+++ /dev/null
@@ -1,57 +0,0 @@
-toArray();
- }
-
- public static function getOptions()
- {
- return ApplicationModule::pluck('name', 'id')->toArray();
- }
-
- public static function edit($id)
- {
- return self::get($id)->toArray();
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
-
- return $id ? self::update($data, $id) : self::create($data);
- }
-
- public static function create($data)
- {
- return ApplicationModule::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
-
- return self::get($id)->update($data);
- }
-
- public static function destroy($id)
- {
- return ApplicationModule::destroy($id);
- }
-
- public static function getName($id)
- {
- return self::get($id)->name;
- }
-
- public static function get($id)
- {
- return ApplicationModule::findOrFail($id);
- }
-}
diff --git a/app/Repositories/Core/App/ApplicationPages.php b/app/Repositories/Core/App/ApplicationPages.php
deleted file mode 100644
index e27e6d82..00000000
--- a/app/Repositories/Core/App/ApplicationPages.php
+++ /dev/null
@@ -1,22 +0,0 @@
-byApplication($application_id)->bySlug($slug)->first();
-
- return $app ? $app->toArray() : null;
- }
-
- public static function getActiveByApplication($application_id)
- {
- $app = ApplicationPage::active()->byApplication($application_id)->get();
-
- return $app ? $app->toArray() : null;
- }
-}
diff --git a/app/Repositories/Core/App/Applications.php b/app/Repositories/Core/App/Applications.php
deleted file mode 100644
index 494c5189..00000000
--- a/app/Repositories/Core/App/Applications.php
+++ /dev/null
@@ -1,118 +0,0 @@
-active()->bySlug($slug)->first();
- }
-
- public static function getAll()
- {
- return Application::all();
- }
-
- public static function getOptions()
- {
- return Application::pluck('name', 'id')->toArray();
- }
-
- public static function edit($id)
- {
- return self::get($id)->toArray();
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
-
- return $id ? self::update($data, $id) : self::create($data);
- }
-
- public static function create($data)
- {
- return Application::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return Application::destroy($id);
- }
-
- public static function getName($id)
- {
- return self::get($id)->name;
- }
-
- public static function get($id)
- {
- return Application::findOrFail($id);
- }
-
- public static function getCurrent()
- {
- $route = explode('.', Route::currentRouteName());
- $app = isset($route[0]) ? $route[0] : null;
- $page = isset($route[1]) ? $route[1] : null;
- $action = isset($route[2]) ? $route[2] : null;
-
- if (self::getBySlug($app)) {
- $data['current'] = self::getBySlug($app)->toArray();
- $application_id = $data['current']['id'];
- $data['page'] = ApplicationPages::getBySlug($application_id, $page);
- $data['pages'] = ApplicationPages::getActiveByApplication($application_id);
- $data['action'] = $action;
- } else {
- $data['current']['slug'] = $app;
- }
- $data['langs'] = Languages::getActive();
- $data['lang'] = Languages::getCurrent();
-
- return $data;
- }
-
- public static function getActives()
- {
- return Application::active()->get()->toArray();
- }
-
- public static function getActivesWithModules()
- {
- return Application::with('modules')->active()->get()->toArray();
- }
-
- public static function getVisibles()
- {
- return Application::visible()->get()->toArray();
- }
-
- public static function getBySlug($slug)
- {
- return Application::active()->bySlug($slug)->first();
- }
-
- public static function toggleActive($id, $active)
- {
- return self::update(['active' => $active], $id);
- }
-
- public static function toggleVisible($id, $visible)
- {
- return self::update(['visible' => $visible], $id);
- }
-}
diff --git a/app/Repositories/Core/Auth/Passwords.php b/app/Repositories/Core/Auth/Passwords.php
index 72f87bdb..5ce753e0 100644
--- a/app/Repositories/Core/Auth/Passwords.php
+++ b/app/Repositories/Core/Auth/Passwords.php
@@ -6,7 +6,7 @@ class Passwords
{
public static function validator()
{
- $validator = new \Password\Validator(new \Password\StringHelper);
+ $validator = new \Password\Validator(new \Password\StringHelper());
$validator->setMinLength(5);
$validator->setMinLowerCaseLetters(2);
$validator->setMinUpperCaseLetters(1);
diff --git a/app/Repositories/Core/Auth/Permissions.php b/app/Repositories/Core/Auth/Permissions.php
index 1a814bf7..828e609f 100644
--- a/app/Repositories/Core/Auth/Permissions.php
+++ b/app/Repositories/Core/Auth/Permissions.php
@@ -3,83 +3,24 @@
namespace App\Repositories\Core\Auth;
use App\Models\Core\Auth\Permission;
-use Yajra\DataTables\DataTables;
+use App\Traits\Model\Basic;
class Permissions
{
+ use Basic;
+
public static function getModules()
{
return Permission::select('module')->distinct('module')->get()->pluck('module');
}
- public static function getOptions()
- {
- return Permission::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
- }
-
- public static function getInfo($id)
- {
- return Permission::find($id);
- }
-
- public static function select_all()
- {
- return self::getAll()->toArray();
- }
-
- public static function select_by_id($id)
- {
- return Permission::find($id)->toArray();
- }
-
- public static function getAll()
- {
- return Permission::orderBy('name', 'asc')->get();
- }
-
public static function getByName($name)
{
return Permission::where('name', $name)->first();
}
- public static function get($id)
+ public static function getModel()
{
- return Permission::findOrFail($id);
- }
-
- public static function getTable($id)
- {
- $datas = Permission::withCount(['users']);
-
- return Datatables::of($datas)->make(true);
- }
-
- public static function delete($id)
- {
- Users::destroyByUniquePermission($id);
-
- return Permission::destroy($id);
- }
-
- public static function store($data)
- {
- return (isset($data['id']) && $data['id']) ? self::update($data) : self::create($data);
- }
-
- public static function create($data)
- {
- $permission = Permission::create($data);
-
- return $permission;
- }
-
- public static function update($data)
- {
- return self::get($data['id'])->update($data);
- }
-
- public static function count()
- {
- return Permission::count();
+ return Permission::query();
}
}
diff --git a/app/Repositories/Core/Auth/Roles.php b/app/Repositories/Core/Auth/Roles.php
index beca9069..8ce4965f 100644
--- a/app/Repositories/Core/Auth/Roles.php
+++ b/app/Repositories/Core/Auth/Roles.php
@@ -4,26 +4,21 @@ namespace App\Repositories\Core\Auth;
use App\Models\Core\Auth\Role;
use App\Models\Core\Auth\RoleUser;
+use App\Traits\Model\Basic;
use Illuminate\Support\Facades\Auth;
use Laratrust\Traits\LaratrustUserTrait;
-use Yajra\DataTables\DataTables;
class Roles
{
- use LaratrustUserTrait;
+ use Basic, LaratrustUserTrait;
public static function getListByRights()
{
- $data = (! Auth::user()->hasRole('admin')) ? Role::whereNotIn('name', ['admin'])->get() : Role::all();
+ $data = ! Auth::user()->hasRole('admin') ? Role::whereNotIn('name', ['admin'])->get() : Role::all();
return $data->pluck('name', 'id')->toArray();
}
- public static function store($input)
- {
- return (isset($input['id']) && $input['id']) ? self::update($input) : self::create($input);
- }
-
public static function create($data)
{
$permissions = array_keys($data['permissions']);
@@ -35,10 +30,9 @@ class Roles
return $role;
}
- // met à jour les informations d'une forme juridique
public static function update($input, $id = false)
{
- $id = ($id) ? $id : $input['id'];
+ $id = $id ? $id : $input['id'];
$permissions = array_keys($input['permissions']);
$role = self::get($id);
$role->update(['name' => $input['name']]);
@@ -47,24 +41,11 @@ class Roles
return $role;
}
- // supprime une forme juridique
- public static function delete($id)
- {
- return Role::destroy($id);
- }
-
- // met à jour le statut actif/inactif d'une forme juridique
public static function toggle_active($id, $active)
{
return Role::find($id)->update(['active' => $active]);
}
- // compte le nombre de formes juridiques
- public static function count()
- {
- return Role::count();
- }
-
public static function getWithPermissions($id)
{
$role = self::get($id)->toArray();
@@ -73,28 +54,11 @@ class Roles
return $role;
}
- public static function getAll()
- {
- return Role::orderBy('name', 'asc')->get();
- }
-
public static function getByName($name)
{
return Role::where('name', $name)->first();
}
- public static function get($id)
- {
- return Role::findOrFail($id);
- }
-
- public static function getTable($id)
- {
- $datas = Role::orderBy('name', 'asc');
-
- return Datatables::of($datas)->make(true);
- }
-
public static function getRolesByUser($user_id = false)
{
$user_id = $user_id ? $user_id : Users::getId();
@@ -112,8 +76,8 @@ class Roles
return self::getUsersByRole($id)->pluck('user_id');
}
- public static function getOptions()
+ public static function getModel()
{
- return Role::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
+ return RoleUser::query();
}
}
diff --git a/app/Repositories/Core/Auth/UserClients.php b/app/Repositories/Core/Auth/UserClients.php
deleted file mode 100644
index b6412d30..00000000
--- a/app/Repositories/Core/Auth/UserClients.php
+++ /dev/null
@@ -1,156 +0,0 @@
-toArray();
- $clients_list = is_array($clients_list) ? $clients_list : [];
-
- if (is_array($clients_existing)) {
- $clients_new = array_diff($clients_list, $clients_existing);
- $clients_to_delete = array_diff($clients_existing, $clients_list);
- } else {
- $clients_new = $clients_list;
- $clients_to_delete = $clients_existing;
- }
-
- $history_element_infos = (! empty($clients_new)) ? self::associateClients($user_id, $clients_new) : false;
- $history_element_infos2 = (! empty($clients_to_delete)) ? self::dissociateClients($user_id, $clients_to_delete) : false;
-
- // $history_element = $old_translated_name['name'];
- // $history_element_id = $documentation_category_id;
- // Histories::insert(190, $history_element_id, $history_element);
-
- $data['nb'] = self::countByUser($user_id);
-
- return $data;
- }
-
- public static function countByUser($id)
- {
- return UserClient::byUser($id)->count();
- }
-
- public static function associateClients($user_id, $clients)
- {
- $history = '';
- foreach ($clients as $key => $client_id) {
- $client = Clients::get($client_id);
- if ($client) {
- self::associate_client($user_id, $client_id);
- $history .= $client['name'].'| ';
- }
- }
-
- return $history;
- }
-
- public static function associate_client($user_id, $client_id)
- {
- self::copyUser($user_id, $client_id);
-
- return UserClient::create(['user_id' => $user_id, 'client_id' => $client_id]);
- }
-
- public static function changePasswordsByUser($user_id, $password)
- {
- try {
- $username = User::find($user_id)->username;
- $connection = app(Connection::class);
- $clients = self::getClientsByUser($user_id);
- foreach ($clients as $client_id) {
- Clients::switchClient($client_id);
- $client_user = User::on($connection->tenantName())->withTrashed()->where('username', $username)->first();
- if ($client_user) {
- $client_user->update(['password' => $password]);
- }
- }
- } catch (Exception $e) {
- }
- // Partners::switchPartner();
- }
-
- public static function copyUser($user_id, $client_id)
- {
- $connection = app(Connection::class);
- $user = User::on($connection->systemName())->find($user_id);
- $password = $user->password;
- Clients::switchClient($client_id);
- $client_user = User::on($connection->tenantName())->withTrashed()->where('username', $user->username)->first();
- if (! $client_user) {
- $user = $user->toArray();
- $user['password'] = $password;
- unset($user['id']);
- unset($user['created_at']);
- $client_user = User::on($connection->tenantName())->create($user);
- $client_user->attachRole('superadministrator');
- } else {
- if ($client_user->trashed()) {
- $client_user->restore();
- }
- $client_user->attachRole('superadministrator');
- }
- // TODO Copy avatar
- //
- // dump($client_user->toArray());
- // exit;
- // $client_user = User::on($connection->tenantName())->firstOrCreate(['username' => $user->username], $user->toArray());
- Partners::switchPartner();
- }
-
- public static function dissociateClients($user_id, $clients)
- {
- $history = '';
- foreach ($clients as $key => $client_id) {
- self::dissociate_client($user_id, $client_id);
- $history .= $client['name'].'| ';
- }
-
- return $history;
- }
-
- public static function dissociate_client($user_id, $client_id)
- {
- self::deleteUser($user_id, $client_id);
-
- return UserClient::byUser($user_id)->byClient($client_id)->delete();
- }
-
- public static function deleteUser($user_id, $client_id)
- {
- $connection = app(Connection::class);
- $user = User::on($connection->systemName())->find($user_id);
- Clients::switchClient($client_id);
- $user = User::on($connection->tenantName())->where('username', $user->username)->get();
- $user->detachRole('superadministrator');
- $user->delete();
- Partners::switchPartner();
- }
-
- public static function delete_associate_clients($id)
- {
- return UserClient::byUser($id)->delete();
- }
-
- public static function select_clients_by_id($id)
- {
- return UserClient::byUser($id)->get()->pluck('client_id')->toArray();
- }
-
- public static function getClientsByUser($id)
- {
- return UserClient::byUser($id)->get()->pluck('client_id');
- }
-
- public static function getUsersByClient($id)
- {
- return UserClient::byClient($id)->get()->pluck('user_id');
- }
-}
diff --git a/app/Repositories/Core/Auth/Users.php b/app/Repositories/Core/Auth/Users.php
index d909fd74..4ceea498 100644
--- a/app/Repositories/Core/Auth/Users.php
+++ b/app/Repositories/Core/Auth/Users.php
@@ -18,7 +18,7 @@ class Users
public static function isAdmin()
{
- return (self::hasRole('admin')) ? true : false;
+ return self::hasRole('admin');
}
public static function getInfo($id = false)
@@ -42,7 +42,7 @@ class Users
if ($data['id'] ?? false) {
unset($data['password']);
}
- $user = ($data['id'] ?? false) ? self::update($data) : self::create($data);
+ $user = $data['id'] ?? false ? self::update($data) : self::create($data);
$user->roles()->sync(array_keys($data['roles'] ?? []));
return $user;
@@ -243,9 +243,10 @@ class Users
$data = Upload::getData($file);
$file_uploaded = Upload::store($file, $targetDir);
$tab = pathinfo($file_uploaded);
- $response['name'] = $tab['basename'];
- return $response;
+ return [
+ 'name' => $tab['basename'],
+ ];
}
public static function update_avatar($id, $avatar)
diff --git a/app/Repositories/Core/Categories.php b/app/Repositories/Core/Categories.php
index 2a24bd3f..5b654413 100644
--- a/app/Repositories/Core/Categories.php
+++ b/app/Repositories/Core/Categories.php
@@ -10,9 +10,8 @@ class Categories
{
$categories = self::getTree(true);
$categories = Arrays::changeKeyName($categories, 'title', 'name');
- $categories = Arrays::changeKeyName($categories, 'key', 'id');
- return $categories;
+ return Arrays::changeKeyName($categories, 'key', 'id');
}
public static function getTreeVisibles($withFolder = false)
@@ -36,7 +35,8 @@ class Categories
public static function getCategoryTreeVisibles($sale_channel_id = false)
{
- return self::getModel()->defaultOrder()->hasAvailableOffersByCategoryParent($sale_channel_id)->visible()->get()->toTree();
+ return self::getModel()->defaultOrder()
+ ->hasAvailableOffersByCategoryParent($sale_channel_id)->visible()->get()->toTree();
}
public static function getChildren($data, $withFolder = false)
@@ -46,7 +46,7 @@ class Categories
$leaf = [];
$leaf['name'] = $item['name'];
$leaf['id'] = $item['id'];
- $children = ($item['children'] ?? false) ? self::getChildren($item['children']) : false;
+ $children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
if ($children) {
$leaf['children'] = $children;
if ($withFolder) {
@@ -57,10 +57,8 @@ class Categories
}
$tree[] = $leaf;
}
- // $tree = collect($tree)->sortBy('name')->toArray();
- $tree = collect($tree)->toArray();
- return $tree;
+ return collect($tree)->toArray();
}
public static function moveTree($node_id, $target_id, $type)
@@ -70,22 +68,21 @@ class Categories
switch ($type) {
case 'after':
- // dump("$node_id After $target_id");
$category->afterNode($category_target);
break;
case 'inside':
- // dump("$node_id inside $target_id");
$category_target->appendNode($category);
break;
+ default:
+ $category->afterNode($category_target);
}
- $category->save();
- return '1';
+ return $category->save();
}
public static function create($data)
{
- $parent = ($data['parent_id'] ?? false) ? self::getNode($data['parent_id']) : self::getRoot();
+ $parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id']) : self::getRoot();
$category = self::getModel()->create(['name' => $data['name']]);
$category->appendToNode($parent)->save();
@@ -101,11 +98,6 @@ class Categories
return $item;
}
- public static function destroy($id)
- {
- // return Category::destroy($id);
- }
-
public static function getRoot()
{
return self::getNode(1);
@@ -119,6 +111,5 @@ class Categories
public static function getModel()
{
return app(Category::class);
- // return app('rinvex.categories.category');
}
}
diff --git a/app/Repositories/Core/DateRange.php b/app/Repositories/Core/DateRange.php
index c5e3e954..e2ab8a9b 100644
--- a/app/Repositories/Core/DateRange.php
+++ b/app/Repositories/Core/DateRange.php
@@ -3,9 +3,8 @@
namespace App\Repositories\Core;
use Carbon\Carbon;
-use League\Period\Period;
-
use function League\Period\interval_after;
+use League\Period\Period;
class DateRange
{
@@ -207,11 +206,6 @@ class DateRange
$range[] = interval_after($day, $duration);
}
- /*
- foreach ($period->dateRangeForward($duration) as $day) {
- $daterange[] = interval_after($day, $duration);
- }
- */
return $range;
}
diff --git a/app/Repositories/Core/DateStats.php b/app/Repositories/Core/DateStats.php
index 68587568..f2296597 100644
--- a/app/Repositories/Core/DateStats.php
+++ b/app/Repositories/Core/DateStats.php
@@ -50,6 +50,6 @@ trait DateStats
public static function getModel()
{
- return new Model;
+ return new Model();
}
}
diff --git a/app/Repositories/Core/DateTime.php b/app/Repositories/Core/DateTime.php
index a6121f09..e324d1fe 100644
--- a/app/Repositories/Core/DateTime.php
+++ b/app/Repositories/Core/DateTime.php
@@ -47,9 +47,9 @@ class DateTime
public static function datetoLocale($date = null)
{
$format = self::getLocaleFormatDate();
- if (! is_null($date) && ! empty($date)) {
+ if ($date) {
$date = Carbon::parse($date)->format($format);
- } elseif ($date === 'now') {
+ } else {
$date = today()->format($format);
}
@@ -59,7 +59,7 @@ class DateTime
public static function datetimeToLocale($date = null)
{
$format = self::getLocaleFormatDatetime();
- if (! is_null($date) && ! empty($date)) {
+ if ($date) {
$date = Carbon::parse($date)->format($format);
} elseif ($date === 'now') {
$date = now()->format($format);
@@ -82,51 +82,50 @@ class DateTime
$date .= ':00';
}
- return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
+ return $date ? Carbon::createFromFormat($format, $date) : null;
}
public static function getCarbonDate($date)
{
$format = self::getLocaleFormatDate();
- return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
+ return $date ? Carbon::createFromFormat($format, $date) : null;
}
public static function convert($date)
{
- return ! empty($date) ? self::getCarbonDate($date)->isoFormat('Y-MM-DD') : null;
+ return $date ? self::getCarbonDate($date)->isoFormat('Y-MM-DD') : null;
}
public static function convertTime($date)
{
- return ! empty($date) ? self::getCarbonTime($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
+ return $date ? self::getCarbonTime($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
}
public static function toLocale($date)
{
$format = self::getLocaleFormatDate();
- return ! empty($date) ? Carbon::parse($date)->Format($format) : null;
+ return $date ? Carbon::parse($date)->Format($format) : null;
}
public static function toISO($date)
{
- return ! empty($date) ? Carbon::parse($date)->isoFormat('Y-MM-DD') : null;
+ return $date ? Carbon::parse($date)->isoFormat('Y-MM-DD') : null;
}
public static function toFr($date)
{
- return ! empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
+ return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
}
public static function toFrTime($date)
{
- return ! empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
+ return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
}
public static function getYearFromDate($date)
{
- // return date_format(DateTime::convert($signature_date), 'Y');
$date = self::convert($date);
$date = date_create($date);
diff --git a/app/Repositories/Core/Debug.php b/app/Repositories/Core/Debug.php
deleted file mode 100644
index a6363284..00000000
--- a/app/Repositories/Core/Debug.php
+++ /dev/null
@@ -1,307 +0,0 @@
-debugbar = DebugBar::getInstance()->debugbar;
- }
-
- public static function isDebugbar()
- {
- return class_exists('Barryvdh\Debugbar\ServiceProvider') ? true : false;
- }
-
- public static function isClockwork()
- {
- return class_exists('Clockwork\Support\Laravel\ClockworkServiceProvider') ? true : false;
- }
-
- public static function start($var = '', $params = [], $txt = '')
- {
- if (! static::isDebug()) {
- return false;
- }
- $var = (empty($var)) ? static::getMethod() : $var;
- $params = (empty($params)) ? static::getArgs() : $params;
- /*
- foreach ($params as $key => $value) {
- $params[$key] = substr($value,30);
- }
- */
- // TODO Fixer la longueur des params string passés
- if (is_null($params)) {
- $params = [];
- }
-
- Timer::start($var, $params);
-
- if (static::isDebugbar()) {
- \Debugbar::startMeasure($var, $txt);
- }
-
- if (static::isClockwork()) {
- // clock()->startEvent($var, $txt);
- }
- }
-
- public static function stop($var = '')
- {
- if (! static::isDebug()) {
- return false;
- }
- $var = (empty($var)) ? static::getMethod() : $var;
- Timer::stop();
-
- if (static::isDebugbar()) {
- \Debugbar::stopMeasure($var);
- }
-
- if (static::isClockwork()) {
- // clock()->endEvent($var);
- }
- }
-
- public static function render($force = false)
- {
- static::dump((string) Timer::result(), '', $force);
- }
-
- public static function memory($force = false)
- {
- static::dump(memory_get_usage(), '', $force);
- }
-
- public static function breakpoint($msg = '', $cat = '', $force = true)
- {
- static::dump($msg, $cat, $force);
- static::header('paramètres');
- static::dump(static::getArgs(), '', $force);
- static::footer('paramètres');
- static::render($force);
- static::backtrace($force);
- exit;
- }
-
- /**
- * dump un message uniquement si debug est true
- *
- * @param string $msg [description]
- * @return [type] [description]
- */
- public static function message($msg, $cat = '')
- {
- if (static::isDebug()) {
- static::dump($msg, $cat);
- }
- }
-
- /**
- * force la sortie d'un dump, sans passer par la debugbar ou test si debug est true
- *
- * @param string $msg [description]
- * @return [type] [description]
- */
- public static function fdump($msg, $cat = '')
- {
- static::dump($msg, $cat, 3);
- }
-
- /**
- * dump un message suivant le handler de sortie prévu (log, debugbar, cli, ...)
- *
- * @param [type] $msg [description]
- * @param bool $force si true, force la sortie en output direct
- * @return [type] [description]
- */
- public static function dump($msg, $cat = '', $force = false)
- {
- $cat = $cat ? $cat : self::getClass();
- if ($force || self::isForcedOutput()) {
- dump(self::getLocation());
- dump($msg);
- }
-
- if (! self::isDebug()) {
- return;
- }
- if (static::isCLI()) {
- self::dumpCli($msg, $cat);
- }
- if (static::isDebugbar()) {
- self::dumpDebugbar($msg, $cat);
- }
- if (static::isClockwork()) {
- self::dumpClockwork($msg, $cat);
- }
-
- }
-
- public static function dumpDebugbar($msg, $cat = '', $force = false)
- {
- \Debugbar::addMessage(self::getLocation(), $cat);
- \Debugbar::addMessage($msg, $cat);
- }
-
- public static function dumpClockwork($msg, $cat = '')
- {
- clock($msg);
- }
-
- public static function dumpCli($msg, $cat = '')
- {
- $climate = new CLImate;
- // $climate->yellow()->bold()->out($message);
- // $climate->white()->bold()->out($output);
- // $climate->out($msg);
- // dump(self::getLocation());
- // dump($msg);
- }
-
- public static function header($titre = '')
- {
- static::dump("*********** $titre ************");
- }
-
- public static function footer($titre = '')
- {
- static::dump("*********** Fin $titre ************");
- }
-
- public static function isDebug()
- {
- return self::getIsDebug() && 1;
- }
-
- public static function isForcedOutput()
- {
- return self::getIsDebug() > 1;
- }
-
- public static function getIsDebug()
- {
- $caller = (array) static::getCaller();
- // dump($caller);
- if ($caller['class']) {
- if (isset($caller['class']::$is_debug)) {
- $is_debug = $caller['class']::$is_debug;
- } else {
- $is_debug = false;
- }
- } else {
- dump('la isDebug::165');
- dump($caller);
- $is_debug = true;
- }
-
- return $is_debug;
- }
-
- public static function backtrace($force = false)
- {
- $txt = '';
- $backtrace = debug_backtrace();
- $backtrace = array_reverse($backtrace);
- foreach ($backtrace as $item) {
- $caller = isset($item['class']) ? $item['class'].$item['type'].$item['function'] : $item['function'];
- $place = isset($item['file']) ? $item['file'].' at '.$item['line'] : '';
- $txt .= "$caller | $place \n";
- }
- static::dump($txt, '', $force);
- // dump($backtrace);
- }
-
- public static function getLocation()
- {
- return static::getMethod().' at '.static::getFile().' line '.static::getLine();
- }
-
- public static function getMethod()
- {
- return static::getClass().static::getType().static::getFunction();
- }
-
- public static function getClass()
- {
- return static::getCaller()->class;
- }
-
- public static function getFunction()
- {
- return static::getCaller()->function;
- }
-
- public static function getType()
- {
- return static::getCaller()->type;
- }
-
- public static function getArgs()
- {
- // dump(static::getCaller()->args);
- return static::getCaller()->args;
- }
-
- public static function getLine()
- {
- return static::getParent()->line;
- }
-
- public static function getFile()
- {
- return static::getParent()->file;
- }
-
- public static function getCaller()
- {
- $backtrace = debug_backtrace();
- // dump($backtrace);
- $k = 1;
- while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
- $k++;
- }
-
- return (object) $backtrace[$k];
- }
-
- public static function getParent()
- {
- $backtrace = debug_backtrace();
- // dump($backtrace);
- $k = 1;
- while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
- $k++;
- }
-
- return (object) $backtrace[$k - 1];
- }
-
- public static function getRoot()
- {
- $backtrace = debug_backtrace();
- $object = isset($backtrace[0]['object']) ? $backtrace[0]['object'] : null;
- $k = 1;
- while (isset($backtrace[$k]) && (! isset($backtrace[$k]['object']) || $object === $backtrace[$k]['object'])) {
- $k++;
- }
-
- return isset($backtrace[$k]['object']) ? $backtrace[$k]['object'] : null;
- }
-
- public static function isCLI()
- {
- return PHP_SAPI == 'cli';
- }
-}
diff --git a/app/Repositories/Core/Export.php b/app/Repositories/Core/Export.php
index 40881e60..a75991b9 100644
--- a/app/Repositories/Core/Export.php
+++ b/app/Repositories/Core/Export.php
@@ -51,20 +51,13 @@ class Export
$styleFont->setBold(true);
$styleFont->setSize(12);
$styleFont->setName('Arial');
- // $styleFont->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$this->sheet->setCellValue($coord, $txt);
- if ($this->debug) {
- echo "Col $col Ligne $lig : $coord Text $txt
";
- }
}
public function writeCell($lig, $col, $txt)
{
$coord = $this->conv($lig, $col);
$this->sheet->setCellValue($coord, $txt);
- if ($this->debug) {
- echo "Col $col Ligne $lig : $coord Text $txt
";
- }
}
public function exportRow($data, $config = null)
@@ -129,26 +122,20 @@ class Export
if ($this->debug) {
return;
}
- // Debug::message($this->xls);
$objWriter = PHPExcel_IOFactory::createWriter($this->xls, 'Excel2007');
- // Debug::message($objWriter);
- // exit;
if (! $this->stockage) {
$this->header();
$objWriter->save('php://output');
} else {
- // $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$objWriter->save('text.xlsx');
}
-
}
public function conv($lig, $col)
{
$c = static::convColtoTxt($col);
- $lig = $this->lig;
- return "$c$lig";
+ return $c.$lig;
}
public function convColtoTxt($col)
diff --git a/app/Repositories/Core/Geolocation.php b/app/Repositories/Core/Geolocation.php
index 14cc6a41..2e520566 100644
--- a/app/Repositories/Core/Geolocation.php
+++ b/app/Repositories/Core/Geolocation.php
@@ -6,10 +6,10 @@ class Geolocation
{
public static function getCoords($address, $zipcode, $city)
{
- if (! (! empty($address) && ! empty($zipcode) && ! empty($city))) {
+ if (! ($address && $zipcode && $city)) {
return;
}
- $address = $address.' , '.$city.' '.$zipcode.' , '.'France';
+ $address .= ' , '.$city.' '.$zipcode.' , France';
$geocode = app('geocoder')->geocode($address)->get();
@@ -17,15 +17,10 @@ class Geolocation
return false;
}
$res = $geocode[0]->getCoordinates()->toArray();
- // dump($res);
$longitude = $res[0];
$latitude = $res[1];
- // dump($latitude);
- // dump($longitude);
- // exit;
return ['latitude' => $latitude, 'longitude' => $longitude];
-
}
public static function autocomplete($query)
diff --git a/app/Repositories/Core/HelperDate.php b/app/Repositories/Core/HelperDate.php
index 4a57764f..3b963fe6 100644
--- a/app/Repositories/Core/HelperDate.php
+++ b/app/Repositories/Core/HelperDate.php
@@ -8,7 +8,7 @@ class HelperDate
{
public static function toLocaleFormat($date)
{
- if (! (! is_null($date) && ! empty($date))) {
+ if (! $date) {
return $date;
}
$locale = session('locale');
diff --git a/app/Repositories/Core/Mail/MailTemplates.php b/app/Repositories/Core/Mail/MailTemplates.php
index 6100f8df..b1bc196a 100644
--- a/app/Repositories/Core/Mail/MailTemplates.php
+++ b/app/Repositories/Core/Mail/MailTemplates.php
@@ -53,9 +53,9 @@ class MailTemplates
$m = new Mustache_Engine();
return $m->render($html_template, $data);
- } else {
- return false;
}
+
+ return false;
}
public static function getModel()
diff --git a/app/Repositories/Core/Medias.php b/app/Repositories/Core/Medias.php
index 432ea179..74ade427 100644
--- a/app/Repositories/Core/Medias.php
+++ b/app/Repositories/Core/Medias.php
@@ -69,7 +69,6 @@ class Medias
public static function getConversion($image, $conversion = '')
{
- // return $conversion ? '/conversions/' . $image->name . '-' . $conversion . self::getExtension($image->file_name) : $image->file_name;
return $conversion ? '/conversions/'.$image->name.'-'.$conversion.'.jpg' : $image->file_name;
}
@@ -86,7 +85,7 @@ class Medias
$id = $image['id'];
$filename = self::getFilename($image);
- return "/storage/$id/$filename";
+ return "/storage/{$id}/{$filename}";
}
public static function getThumbSrc($image)
diff --git a/app/Repositories/Core/Menu/Builder.php b/app/Repositories/Core/Menu/Builder.php
index b7d31e8b..be639c9b 100644
--- a/app/Repositories/Core/Menu/Builder.php
+++ b/app/Repositories/Core/Menu/Builder.php
@@ -2,31 +2,18 @@
namespace App\Repositories\Core\Menu;
-use Auth;
-use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Auth;
use Lavary\Menu\Builder as LavaryMenuBuilder;
-/**
- * Class Builder.
- *
- * @property Collection $items;
- */
class Builder extends LavaryMenuBuilder
{
private $root = [];
- /**
- * Adds an item to the menu.
- *
- * @param string $title
- * @param string $options
- * @return \Lavary\Menu\Item|Item
- */
public function add($title, $options = '')
{
$title = sprintf('%s', $title);
- $id = isset($options['id']) ? $options['id'] : $this->id();
+ $id = $options['id'] ?? $this->id();
$item = new Item($this, $id, $title, $options);
@@ -37,7 +24,7 @@ class Builder extends LavaryMenuBuilder
if (isset($options['role']) || isset($options['permission'])) {
$ability = ['admin'];
if (isset($options['role'])) {
- $ability = $ability + explode(',', $options['role']);
+ $ability += explode(',', $options['role']);
}
$permission = null;
@@ -57,14 +44,6 @@ class Builder extends LavaryMenuBuilder
return $item;
}
- /**
- * Add an item to a existing menu item as a submenu item.
- *
- * @param $id Id of the menu item to attach to
- * @param $title Title of the sub item
- * @param string $options
- * @return Lavary\Menu\Item
- */
public function addTo($id, $title, $options = '')
{
$parent = $this->whereId($id)->first();
@@ -72,8 +51,6 @@ class Builder extends LavaryMenuBuilder
if (isset($parent)) {
if (! isset($this->root[$parent->id])) {
$parent->attr(['url' => '#', 'class' => 'treeview']);
- // $str = '';
- // $parent->append($str);
$this->root[$parent->id] = true;
}
diff --git a/app/Repositories/Core/Menu/Item.php b/app/Repositories/Core/Menu/Item.php
index 1836c4d4..3d46deb0 100644
--- a/app/Repositories/Core/Menu/Item.php
+++ b/app/Repositories/Core/Menu/Item.php
@@ -6,12 +6,6 @@ use Lavary\Menu\Item as LavaryMenuItem;
class Item extends LavaryMenuItem
{
- /**
- * Set the item icon using font-awesome.
- *
- *
- * @return self
- */
public function icon($icon)
{
$this->prepend(sprintf('', $icon));
@@ -19,12 +13,6 @@ class Item extends LavaryMenuItem
return $this;
}
- /**
- * Set the item order.
- *
- *
- * @return self
- */
public function order($order)
{
$this->data('order', $order);
@@ -32,15 +20,9 @@ class Item extends LavaryMenuItem
return $this;
}
- /**
- * Make the item active.
- *
- * @param string|array $routes
- * @return self
- */
public function activeIfRoute($routes = null)
{
- if (! empty($routes)) {
+ if ($routes) {
if (is_string($routes)) {
$routes = [$routes];
}
@@ -56,7 +38,6 @@ class Item extends LavaryMenuItem
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
}
- // dump($this);
return $this;
}
diff --git a/app/Repositories/Core/Menu/Logs.php b/app/Repositories/Core/Menu/Logs.php
index 3038d70f..e191a502 100644
--- a/app/Repositories/Core/Menu/Logs.php
+++ b/app/Repositories/Core/Menu/Logs.php
@@ -2,8 +2,6 @@
namespace Sebastienheyd\Boilerplate\Menu;
-use Sebastienheyd\Boilerplate\Menu\Builder as Builder;
-
class Logs
{
public function make(Builder $menu)
@@ -12,20 +10,18 @@ class Logs
->id('logs')
->order(1100);
- $menu->addTo(
- 'logs', __('boilerplate::logs.menu.stats'), [
- 'route' => 'boilerplate.logs.dashboard',
- 'permission' => 'logs', ]
- )
- ->order(1110)
- ->activeIfRoute('boilerplate.logs.dashboard');
+ $menu->addTo('logs', __('boilerplate::logs.menu.stats'), [
+ 'route' => 'boilerplate.logs.dashboard',
+ 'permission' => 'logs',
+ ])->order(1110)->activeIfRoute('boilerplate.logs.dashboard');
- $menu->addTo(
- 'logs', __('boilerplate::logs.menu.reports'), [
- 'route' => 'boilerplate.logs.list',
- 'permission' => 'logs', ]
- )
- ->order(1120)
- ->activeIfRoute(['boilerplate.logs.list', 'boilerplate.logs.show', 'boilerplate.logs.filter']);
+ $menu->addTo('logs', __('boilerplate::logs.menu.reports'), [
+ 'route' => 'boilerplate.logs.list',
+ 'permission' => 'logs',
+ ])->order(1120)->activeIfRoute([
+ 'boilerplate.logs.list',
+ 'boilerplate.logs.show',
+ 'boilerplate.logs.filter',
+ ]);
}
}
diff --git a/app/Repositories/Core/Menu/Users.php b/app/Repositories/Core/Menu/Users.php
index e7549d0b..fee78933 100644
--- a/app/Repositories/Core/Menu/Users.php
+++ b/app/Repositories/Core/Menu/Users.php
@@ -2,8 +2,6 @@
namespace App\Repositories\Core\Menu;
-use App\Repositories\Core\Menu\Builder as Builder;
-
class Users
{
public function make(Builder $menu)
@@ -12,26 +10,20 @@ class Users
->id('access')
->order(1000);
- $menu->addTo(
- 'access', __('boilerplate::users.list.title'), [
- 'route' => 'boilerplate.users.index',
- 'permission' => 'users_crud', ]
- )
- ->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
+ $menu->addTo('access', __('boilerplate::users.list.title'), [
+ 'route' => 'boilerplate.users.index',
+ 'permission' => 'users_crud',
+ ])->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
- $menu->addTo(
- 'access', __('boilerplate::users.create.title'), [
- 'route' => 'boilerplate.users.create',
- 'permission' => 'users_crud', ]
- )
- ->activeIfRoute('boilerplate.users.create');
+ $menu->addTo('access', __('boilerplate::users.create.title'), [
+ 'route' => 'boilerplate.users.create',
+ 'permission' => 'users_crud',
+ ])->activeIfRoute('boilerplate.users.create');
- $menu->addTo(
- 'access', __('boilerplate::layout.role_management'), [
- 'route' => 'boilerplate.roles.index',
- 'permission' => 'roles_crud', ]
- )
- ->activeIfRoute('boilerplate.roles.*');
+ $menu->addTo('access', __('boilerplate::layout.role_management'), [
+ 'route' => 'boilerplate.roles.index',
+ 'permission' => 'roles_crud',
+ ])->activeIfRoute('boilerplate.roles.*');
$menu->addTo('access', __('boilerplate::users.profile.title'), ['route' => 'boilerplate.user.profile'])
->activeIfRoute('boilerplate.user.profile');
diff --git a/app/Repositories/Core/Number.php b/app/Repositories/Core/Number.php
index bc506024..6d1d2db9 100644
--- a/app/Repositories/Core/Number.php
+++ b/app/Repositories/Core/Number.php
@@ -9,14 +9,12 @@ class Number
{
public static function price($value)
{
- $formatter = new Numeral;
- $languageManager = new LanguageManager;
+ $formatter = new Numeral();
+ $languageManager = new LanguageManager();
$languageManager->setCulture('fr-FR');
$formatter->setLanguageManager($languageManager);
- $price = $formatter->format($value, '0,0');
-
- return $price;
+ return $formatter->format($value, '0,0');
}
}
diff --git a/app/Repositories/Core/Stat.php b/app/Repositories/Core/Stat.php
index d3916183..58c7fb0a 100644
--- a/app/Repositories/Core/Stat.php
+++ b/app/Repositories/Core/Stat.php
@@ -42,7 +42,7 @@ class Stat
public static function getStatsbyMultiVar($var, $var_option = '')
{
- if (empty($var_option)) {
+ if ($var_option) {
$var_option = $var;
}
$options = self::getOption($var_option);
@@ -52,39 +52,34 @@ class Stat
public static function getCountByPeriod($var, $begin, $end)
{
- $count = self::getModel()
+ return self::getModel()
->whereBetween($var, $begin, $end)
->count();
-
- return $count;
}
public static function getCountbyVar($var)
{
$db = self::getInstance()->app->db;
- $data = self::getModel()
- ->select($db::raw("count(id) as y, $var as name"))
+
+ return self::getModel()
+ ->select($db::raw("count(id) as y, {$var} as name"))
->groupBy($var)
->get();
-
- // var_Debug::message($data);
- return $data;
}
public static function getStatsbyOptions($var, $var_option = '')
{
- if (empty($var_option)) {
+ if ($var_option ?? false) {
$var_option = $var;
}
$options = self::getInstance()->controller->getOption($var_option);
$nb = self::getCountbyOption($var);
- // var_Debug::message($nb);
+ $data = [];
foreach ($options as $key => $value) {
$y = (int) $nb[$key];
$data[] = ['y' => $y, 'name' => $value];
}
- // var_Debug::message($data);
return $data;
}
@@ -108,6 +103,7 @@ class Stat
public static function getStatsbyMultiOptions($var, $options)
{
+ $data = [];
foreach ($options as $key => $value) {
$nb = self::getCountbyBin($var, $key);
$data[] = ['y' => $nb, 'name' => $value];
@@ -119,11 +115,8 @@ class Stat
public static function getCountbyBin($var, $value)
{
$bit = pow(2, $value);
- $count = self::getModel()
- ->where($var, '&', $bit)
- ->count();
- return $count;
+ return self::getModel()->where($var, '&', $bit)->count();
}
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')
diff --git a/app/Repositories/Core/Trees.php b/app/Repositories/Core/Trees.php
index 1736adca..a655fedd 100644
--- a/app/Repositories/Core/Trees.php
+++ b/app/Repositories/Core/Trees.php
@@ -18,7 +18,7 @@ class Trees
$leaf = [];
$leaf['name'] = $item['name'];
$leaf['id'] = $item['id'];
- $children = (isset($item['children'])) ? self::getChildren($item['children']) : false;
+ $children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
if ($children) {
$leaf['children'] = $children;
}
@@ -35,22 +35,21 @@ class Trees
switch ($type) {
case 'after':
- // dump("$node_id After $target_id");
$item->afterNode($item_target);
break;
case 'inside':
- // dump("$node_id inside $target_id");
$item_target->appendNode($item);
break;
+ default:
+ $item->afterNode($item_target);
}
- $item->save();
- return '1';
+ return $item->save();
}
public static function create($data, $model)
{
- $parent = (isset($data['parent_id']) && $data['parent_id']) ? self::getNode($data['parent_id']) : self::getRoot();
+ $parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id']) : self::getRoot();
$tree = $model->create(['name' => $data['name']]);
$tree->appendToNode($parent)->save();
diff --git a/app/Repositories/Core/Upload.php b/app/Repositories/Core/Upload.php
index d6948d57..277eb8f0 100644
--- a/app/Repositories/Core/Upload.php
+++ b/app/Repositories/Core/Upload.php
@@ -3,38 +3,31 @@
namespace App\Repositories\Core;
use Illuminate\Support\Facades\Storage;
-use Intervention\Image\Facades\Image as Image;
+use Intervention\Image\Facades\Image;
class Upload
{
public static function getData($file)
{
- $data['filename'] = $file->getClientOriginalName();
- $data['filetype'] = $file->getClientOriginalExtension();
- $data['filesize'] = $file->getSize();
- $data['mime'] = $file->getMimeType();
-
- return $data;
+ return [
+ 'filename' => $file->getClientOriginalName(),
+ 'filetype' => $file->getClientOriginalExtension(),
+ 'filesize' => $file->getSize(),
+ 'mime' => $file->getMimeType(),
+ ];
}
public static function getUuid($file, $data)
{
- $data = (is_array($data)) ? (object) $data : $data;
+ $data = is_array($data) ? (object) $data : $data;
$pos = strrpos($file, '/');
$uuid = substr($file, $pos + 1);
- $uuid = pathinfo($uuid, PATHINFO_FILENAME);
- return $uuid;
+ return pathinfo($uuid, PATHINFO_FILENAME);
}
public static function storeByVar($var, $path, $public = false)
{
- // check if filename exists
- // store
- // Storage::disk('local')->put('file.txt', 'Contents');
- // $path = Storage::putFile('avatars', $request->file('avatar'));
- // $path = $request->file('avatar')->storeAs('avatars',$request->user()->id,'s3');
- // $path = $request->file('avatar')->storePublicly('avatars', 's3');
$request = Request();
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
@@ -43,14 +36,11 @@ class Upload
public static function store($file, $path)
{
return Storage::putFile($path, $file);
- // return $file->store($filepath);
}
public static function storePublic($file, $filepath)
{
return Storage::putFile($filepath, $file, 'public');
- // $filepath = 'public/' . $filepath;
- // return $file->store($filepath);
}
public static function createThumb($file, $size, $sub = false)
@@ -61,12 +51,6 @@ class Upload
return Image::make($filename)->orientate()->widen($size)->save($thumb);
}
- /*
- public static function getPath($file) {
- return 'public/' . self::getFilename($file);
- }
- */
-
public static function getPublicPath($file)
{
return storage_path('app/public/'.self::getFilename($file));
@@ -94,7 +78,7 @@ class Upload
public static function getFilename($file)
{
- $file = (is_array($file)) ? (object) $file : $file;
+ $file = is_array($file) ? (object) $file : $file;
return $file->filepath.'/'.self::getName($file);
}
@@ -102,24 +86,18 @@ class Upload
public static function getThumbFilename($file, $sub = false)
{
$sub = $sub ? $sub : 'thumbs/';
- $file = (is_array($file)) ? (object) $file : $file;
+ $file = is_array($file) ? (object) $file : $file;
return $file->filepath.'/'.$sub.self::getName($file);
}
public static function getName($file)
{
- $file = (is_array($file)) ? (object) $file : $file;
+ $file = is_array($file) ? (object) $file : $file;
return $file->uuid.'.'.strtolower($file->filetype);
}
- /**
- * [fix problem path with Storage on Windows]
- *
- * @param [type] $path [description]
- * @return [type] [description]
- */
public static function fix($path)
{
if (! self::isWindows()) {
diff --git a/app/Repositories/Core/User/Basket.php b/app/Repositories/Core/User/Basket.php
index 14f798a7..268aab58 100644
--- a/app/Repositories/Core/User/Basket.php
+++ b/app/Repositories/Core/User/Basket.php
@@ -42,7 +42,8 @@ class Basket
public static function remove($key, $value)
{
$data = self::get($key);
- if (($index = array_search($value, $data)) !== false) {
+ $index = array_search($value, $data);
+ if ($index !== false) {
unset($data[$index]);
}
diff --git a/app/Repositories/Core/User/Notifications/NewUser.php b/app/Repositories/Core/User/Notifications/NewUser.php
index c3095c8b..79fec2ba 100644
--- a/app/Repositories/Core/User/Notifications/NewUser.php
+++ b/app/Repositories/Core/User/Notifications/NewUser.php
@@ -5,67 +5,45 @@ namespace App\Repositories\Core\User\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
+use Illuminate\Support\Facades\Auth;
class NewUser extends Notification
{
use Queueable;
- /**
- * Get the notification's delivery channels.
- *
- * @param mixed $notifiable
- * @return string[]
- */
public function via($notifiable)
{
return ['mail'];
}
- /**
- * Get the mail representation of the notification.
- *
- * @param mixed $notifiable
- * @return \Illuminate\Notifications\Messages\MailMessage
- */
public function toMail($notifiable)
{
- $currentUser = \Auth::user();
+ $currentUser = Auth::user();
return (new MailMessage())
->markdown('notifications.email')
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
->subject(__('notifications.newuser.subject', ['name' => config('app.name')]))
->line(
- __(
- 'notifications.newuser.intro', [
- 'name' => $currentUser->first_name.' '.$currentUser->last_name,
- ]
- )
+ __('notifications.newuser.intro', [
+ 'name' => $currentUser->first_name.' '.$currentUser->last_name,
+ ])
)
->action(
__('notifications.newuser.button'),
route('users.firstlogin', $notifiable->remember_token)
)
->salutation(
- __(
- 'notifications.salutation', [
- 'name' => $currentUser->first_name.' '.$currentUser->last_name,
- ]
- )
+ __('notifications.salutation', [
+ 'name' => $currentUser->first_name.' '.$currentUser->last_name,
+ ])
)
->line(__('notifications.newuser.outro'));
}
- /**
- * Get the array representation of the notification.
- *
- * @param mixed $notifiable
- * @return array
- */
public function toArray($notifiable)
{
return [
- //
];
}
}
diff --git a/app/Repositories/Core/User/Notifications/ResetPassword.php b/app/Repositories/Core/User/Notifications/ResetPassword.php
index fcb02f26..e89f64be 100644
--- a/app/Repositories/Core/User/Notifications/ResetPassword.php
+++ b/app/Repositories/Core/User/Notifications/ResetPassword.php
@@ -6,13 +6,6 @@ use Illuminate\Notifications\Messages\MailMessage;
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
{
- /**
- * Get the mail representation of the notification.
- *
- * @param mixed $notifiable
- * @return \Illuminate\Notifications\Messages\MailMessage
- */
- /*
public function toMail($notifiable)
{
return (new MailMessage())
@@ -26,5 +19,4 @@ class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
)
->line(__('notifications.resetpassword.outro'));
}
- */
}
diff --git a/app/Repositories/Core/User/ShopCartStorage.php b/app/Repositories/Core/User/ShopCartStorage.php
index 5ba6a869..35c41546 100644
--- a/app/Repositories/Core/User/ShopCartStorage.php
+++ b/app/Repositories/Core/User/ShopCartStorage.php
@@ -19,12 +19,12 @@ class ShopCartStorage
}
return new CartCollection(CartStorage::find($key)->cart_data);
-
}
public function put($key, $value)
{
- if ($row = CartStorage::find($key)) {
+ $row = CartStorage::find($key);
+ if ($row) {
$row->cart_data = $value;
$row->save();
} else {
diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php
index cdcdc18b..73939c72 100644
--- a/app/Repositories/Shop/Articles.php
+++ b/app/Repositories/Shop/Articles.php
@@ -50,6 +50,7 @@ class Articles
public static function getSiblingsDescriptions($id)
{
+ $data = [];
$siblings = self::getSiblings($id);
foreach ($siblings as $sibling) {
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
@@ -76,6 +77,7 @@ class Articles
public static function getOptionsWithNature()
{
+ $data = [];
$articles = Article::with(['article_nature'])->get();
foreach ($articles as $article) {
$data[$article->id] = ($article->article_nature->name ?? null).' - '.$article->name;
@@ -117,6 +119,7 @@ class Articles
public static function getFullDescriptionByArticle($article)
{
+ $data = [];
switch ($article->product_type) {
case 'App\Models\Botanic\Variety':
$data['variety'] = $article->product->description;
@@ -141,13 +144,6 @@ class Articles
if ($siblings) {
array_push($data, $siblings);
}
- /*
- $data['resume'] = ($data['semences'] ?? null) .
- ($data['plants'] ?? null) .
- ($data['variety'] ?? null) .
- ($data['merchandise'] ?? null) .
- ($data['plus'] ?? null);
- */
$data['description'] = $article->description;
return $data;
@@ -155,6 +151,7 @@ class Articles
public static function getArticlesByHomepage()
{
+ $data = [];
$shelves = Categories::getByHomepage();
foreach ($shelves as $shelve) {
$data[] = [
@@ -285,7 +282,7 @@ class Articles
$article_nature_ids = $options['article_nature_ids'] ?? false;
$product_type = $options['product_type'] ?? false;
- $model = ($options['homepage'] ?? false) ? Article::homepage()->visible() : Article::visible();
+ $model = $options['homepage'] ?? false ? Article::homepage()->visible() : Article::visible();
$model = $category_id ? $model->byCategoryParent($category_id) : $model;
$model = $tags ? $model->byTags($tags) : $model;
$model = $search ? $model->search($search) : $model;
@@ -307,7 +304,9 @@ class Articles
public static function getFull($id)
{
- $data['article'] = self::getArticleEdit($id);
+ $data = [
+ 'article' => self::getArticleEdit($id),
+ ];
return self::getMeta($data);
}
@@ -333,6 +332,7 @@ class Articles
public static function getInheritedByProduct($product_id, $product_type)
{
+ $data = [];
switch ($product_type) {
case 'App\Models\Botanic\Variety':
$product = Varieties::get($product_id);
@@ -414,7 +414,6 @@ class Articles
$data['categories_options'] = Categories::getOptions();
$data['natures_options'] = ArticleNatures::getOptions();
- // $data['packages'] = ($data['article']['article_family_id'] ?? false) ? Packages::getSelectByFamily($data['article']['article_family_id']) : [];
$data['tags_list'] = TagGroups::getTreeTags();
$data['models_options'] = [
'App\Models\Botanic\Specie' => 'Espèces',
@@ -439,7 +438,7 @@ class Articles
{
$models = self::getProductTypesModelsByCategory($category_id);
- return (($models[0] ?? false) == Merchandise::class) ? 'merchandise' : 'botanic';
+ return ($models[0] ?? false) === Merchandise::class ? 'merchandise' : 'botanic';
}
public static function getProductTypesModelsByCategory($category_id)
@@ -549,6 +548,7 @@ class Articles
$merchandise = $article->product ?? false;
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
break;
+ default:
}
return $images;
@@ -575,6 +575,7 @@ class Articles
case 'App\Models\Shop\Merchandise':
$image = $article->product->image ?? false;
break;
+ default:
}
return $image;
@@ -591,9 +592,6 @@ class Articles
$tags = $data['tags'] ?? false;
unset($data['tags']);
- $prices = $data['prices'] ?? false;
- unset($data['prices']);
-
$article = self::store($data);
self::storeImages($article, $images);
self::storeCategories($article, $categories);
diff --git a/app/Repositories/Shop/Baskets.php b/app/Repositories/Shop/Baskets.php
index a8561965..824fd28b 100644
--- a/app/Repositories/Shop/Baskets.php
+++ b/app/Repositories/Shop/Baskets.php
@@ -9,7 +9,7 @@ class Baskets
public static function addBasket($offerId, $quantity = 1, $update = false)
{
if (ShopCart::has($offerId) && ! $quantity) {
- $ret = ShopCart::remove($offerId);
+ ShopCart::remove($offerId);
}
$data = $quantity ? self::getBasketData($offerId, $quantity) : false;
@@ -28,6 +28,7 @@ class Baskets
$total = 0;
$totalTaxed = 0;
$totalWeight = 0;
+ $detail = [];
$basket = ShopCart::getContent();
$offers = Offers::getWithVariationByIds(self::getIds());
@@ -42,7 +43,7 @@ class Baskets
}
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
- $data = [
+ return [
'detail' => $detail,
'total' => $total,
'taxes' => $totalTaxed - $total,
@@ -54,8 +55,6 @@ class Baskets
'weight' => $totalWeight,
'sale_channel' => SaleChannels::getArray($saleChannelId),
];
-
- return $data ?? false;
}
public static function getRowDetail($item, $offer, $prices, $weight)
@@ -132,7 +131,6 @@ class Baskets
public static function getArticleName(&$offer)
{
return $offer->article->name;
- // return $offer->article->name . ' (' . $offer->variation->name . ')';
}
public static function getIds()
diff --git a/app/Repositories/Shop/Categories.php b/app/Repositories/Shop/Categories.php
index c9f14e79..d04d3074 100644
--- a/app/Repositories/Shop/Categories.php
+++ b/app/Repositories/Shop/Categories.php
@@ -5,9 +5,12 @@ namespace App\Repositories\Shop;
use App\Models\Shop\Category;
use App\Repositories\Core\Categories as CategoryTrees;
use App\Repositories\Core\Tag;
+use App\Traits\Model\Basic;
class Categories
{
+ use Basic;
+
public static function getAncestorsByArticle($id)
{
$category = Articles::get($id)->categories()->first();
@@ -31,16 +34,6 @@ class Categories
return Category::hasAvailableOffers()->visible()->homepage()->orderBy('name', 'asc')->get();
}
- public static function getAll()
- {
- return Category::orderBy('name', 'asc')->get();
- }
-
- public static function get($id, $relations = false)
- {
- return $relations ? Category::with($relations)->findOrFail($id) : Category::findOrFail($id);
- }
-
public static function getFull($id)
{
$category = self::get($id, ['Parent']);
@@ -72,11 +65,6 @@ class Categories
return CategoryTrees::getTree();
}
- public static function getOptions()
- {
- return Category::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
- }
-
public static function storeFull($data)
{
$images = $data['images'] ?? false;
@@ -92,13 +80,6 @@ class Categories
return $category;
}
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
-
- return $id ? self::update($data, $id) : self::create($data);
- }
-
public static function storeTags($category, $tags)
{
return Tag::storeTags($category, $tags);
@@ -146,26 +127,7 @@ class Categories
return CategoryTrees::moveTree($node_id, $target_id, $type);
}
- public static function create($data)
- {
- return Category::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? (int) $id : $data['id'];
- $category = self::get($id);
- $ret = $category->update($data);
-
- return $category;
- }
-
- public static function destroy($id)
- {
- return Category::destroy($id);
- }
-
- public static function toggle_visible($id, $visible)
+ public static function toggleVisible($id, $visible)
{
return self::update(['visible' => $visible], $id);
}
@@ -179,4 +141,9 @@ class Categories
{
return app('rinvex.categories.category')->find(1);
}
+
+ public static function getModel()
+ {
+ return Category::query();
+ }
}
diff --git a/app/Repositories/Shop/CustomerAddresses.php b/app/Repositories/Shop/CustomerAddresses.php
index 55192dd5..4ed48eb3 100644
--- a/app/Repositories/Shop/CustomerAddresses.php
+++ b/app/Repositories/Shop/CustomerAddresses.php
@@ -21,16 +21,16 @@ class CustomerAddresses
'zipcode' => $data['delivery_zipcode'],
'city' => $data['delivery_city'],
]);
- } else {
- return self::store([
- 'customer_id' => $userId,
- 'name' => $name,
- 'address' => $data['address'],
- 'address2' => $data['address2'],
- 'zipcode' => $data['zipcode'],
- 'city' => $data['city'],
- ]);
}
+
+ return self::store([
+ 'customer_id' => $userId,
+ 'name' => $name,
+ 'address' => $data['address'],
+ 'address2' => $data['address2'],
+ 'zipcode' => $data['zipcode'],
+ 'city' => $data['city'],
+ ]);
}
public static function toggleActive($id, $active)
diff --git a/app/Repositories/Shop/Customers.php b/app/Repositories/Shop/Customers.php
index 87381898..bd2208ae 100644
--- a/app/Repositories/Shop/Customers.php
+++ b/app/Repositories/Shop/Customers.php
@@ -62,7 +62,6 @@ class Customers
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'orders' => $datatableOrders->html(),
];
-
}
public static function getAvatar($id = false)
@@ -160,14 +159,10 @@ class Customers
public static function storeFull($data)
{
- // $invoices = $data['invoices'];
$saleChannels = $data['sale_channels'];
- // unset($data['invoices']);
unset($data['sale_channels']);
$customer = self::store($data);
if ($customer) {
- // self::storeAddresses($customer->id, $deliveries);
- // self::storeAddresses($customer->id, $invoices);
self::storeSaleChannels($customer->id, $saleChannels);
}
@@ -179,11 +174,9 @@ class Customers
if (! $deliveries) {
return false;
}
- $deliveries = collect($deliveries)->transform(
- function ($item) {
- return (int) $item;
- }
- )->toArray();
+ $deliveries = collect($deliveries)->transform(function ($item) {
+ return (int) $item;
+ })->toArray();
return $customer->deliveries()->sync($deliveries);
}
diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php
index 286589d6..f07295aa 100644
--- a/app/Repositories/Shop/Offers.php
+++ b/app/Repositories/Shop/Offers.php
@@ -127,9 +127,8 @@ class Offers
$tags = Categories::getTagsByCategory($category);
$offers1 = self::getByCategory($category_id)->toArray();
$offers2 = self::getByTags($tags)->toArray();
- $data = array_merge($offers1, $offers2);
- return $data;
+ return array_merge($offers1, $offers2);
}
public static function getByCategory($category_id)
diff --git a/app/Repositories/Shop/Prices.php b/app/Repositories/Shop/Prices.php
index bc3ac1bc..3bfad6e1 100644
--- a/app/Repositories/Shop/Prices.php
+++ b/app/Repositories/Shop/Prices.php
@@ -3,59 +3,25 @@
namespace App\Repositories\Shop;
use App\Models\Shop\Price;
-use Yajra\DataTables\DataTables;
+use App\Traits\Model\Basic;
class Prices
{
+ use Basic;
+
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();
-
- return $data;
+ return [
+ 'prices' => Price::byArticle($id)->notGeneric()->get()->toArray(),
+ 'generics' => Price::byArticle($id)->generic()->with([
+ 'generic.prices',
+ 'generic.category',
+ ])->get()->toArray(),
+ ];
}
- public static function getDatatable()
+ public static function getModel()
{
- $model = Price::orderBy('name');
-
- return Datatables::of($model)->make(true);
- }
-
- public static function getAll()
- {
- return Price::orderBy('name', 'asc')->get();
- }
-
- public static function get($id)
- {
- return Price::find($id);
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
- $item = $id ? self::update($data) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return Price::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return Price::destroy($id);
+ return Price::query();
}
}
diff --git a/app/Repositories/Shop/TagGroups.php b/app/Repositories/Shop/TagGroups.php
index 209fb721..d24426dc 100644
--- a/app/Repositories/Shop/TagGroups.php
+++ b/app/Repositories/Shop/TagGroups.php
@@ -4,14 +4,12 @@ namespace App\Repositories\Shop;
use App\Models\Shop\Tag;
use App\Models\Shop\TagGroup;
+use App\Traits\Model\Basic;
use Illuminate\Support\Str;
class TagGroups
{
- public static function getOptions()
- {
- return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray();
- }
+ use Basic;
public static function getWithTagsAndCountOffers($category_id = false)
{
@@ -62,11 +60,6 @@ class TagGroups
return $tags;
}
- public static function getAll()
- {
- return TagGroup::orderBy('name', 'asc')->get();
- }
-
public static function getSlug($id)
{
return self::get($id)->slug ?? '';
@@ -77,18 +70,6 @@ class TagGroups
return self::get($id)->name ?? '';
}
- public static function get($id)
- {
- return TagGroup::find($id);
- }
-
- public static function store($data)
- {
- $item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
-
- return $item->id;
- }
-
public static function create($data)
{
$data['slug'] = Str::slug($data['name']);
@@ -109,13 +90,13 @@ class TagGroups
return $model;
}
- public static function destroy($id)
- {
- return TagGroup::destroy($id);
- }
-
public static function toggleVisible($id, $visible)
{
return self::update(['visible' => $visible], $id);
}
+
+ public static function getModel()
+ {
+ return TagGroup::query();
+ }
}
diff --git a/app/Repositories/Shop/Tags.php b/app/Repositories/Shop/Tags.php
index 8b43e708..5ae5c5de 100644
--- a/app/Repositories/Shop/Tags.php
+++ b/app/Repositories/Shop/Tags.php
@@ -29,6 +29,7 @@ class Tags
public static function getOptionsFullName()
{
+ $data = [];
$tags = Tag::with('tag_group')->get()->toArray();
foreach ($tags as $tag) {
$data[$tag['id']] = $tag['tag_group']['name'].'-'.$tag['name'];
@@ -61,7 +62,7 @@ class Tags
public static function store($data)
{
- $item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
+ $item = $data['id'] ?? false ? self::update($data) : self::create($data);
return $item->id;
}
@@ -71,9 +72,8 @@ class Tags
$data['slug'] = self::buildSlug($data);
$data['group'] = TagGroups::getName($data['tag_group_id']);
$data['sort_order'] = self::getNewOrder($data['tag_group_id']);
- $tag = Tag::create($data);
- return $tag;
+ return Tag::create($data);
}
public static function update($data, $id = false)
diff --git a/app/Repositories/Shop/TariffUnities.php b/app/Repositories/Shop/TariffUnities.php
index 826724d1..a8cf2068 100644
--- a/app/Repositories/Shop/TariffUnities.php
+++ b/app/Repositories/Shop/TariffUnities.php
@@ -3,48 +3,19 @@
namespace App\Repositories\Shop;
use App\Models\Shop\TariffUnity;
+use App\Traits\Model\Basic;
class TariffUnities
{
+ use Basic;
+
public static function getOptions()
{
return TariffUnity::orderBy('id', 'asc')->pluck('value', 'id')->toArray();
}
- public static function getAll()
+ public static function getModel()
{
- return TariffUnity::orderBy('name', 'asc')->get();
- }
-
- public static function get($id)
- {
- return TariffUnity::find($id);
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
- $item = $id ? self::update($data, $id) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return TariffUnity::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return TariffUnity::destroy($id);
+ return TariffUnity::query();
}
}
diff --git a/app/Repositories/Shop/Taxes.php b/app/Repositories/Shop/Taxes.php
index f4a1e330..9ee31547 100644
--- a/app/Repositories/Shop/Taxes.php
+++ b/app/Repositories/Shop/Taxes.php
@@ -3,9 +3,12 @@
namespace App\Repositories\Shop;
use App\Models\Shop\Tax;
+use App\Traits\Model\Basic;
class Taxes
{
+ use Basic;
+
public static function getOptions()
{
return Tax::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
@@ -16,35 +19,8 @@ class Taxes
return Tax::orderBy('value', 'asc')->get();
}
- public static function get($id)
+ public static function getModel()
{
- return Tax::find($id);
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
- $item = $id ? self::update($data) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return Tax::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return Tax::destroy($id);
+ return Tax::query();
}
}
diff --git a/app/Repositories/Shop/Unities.php b/app/Repositories/Shop/Unities.php
index 191ee464..288dc500 100644
--- a/app/Repositories/Shop/Unities.php
+++ b/app/Repositories/Shop/Unities.php
@@ -3,9 +3,12 @@
namespace App\Repositories\Shop;
use App\Models\Shop\Unity;
+use App\Traits\Model\Basic;
class Unities
{
+ use Basic;
+
public static function getOptions()
{
return Unity::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
@@ -26,35 +29,8 @@ class Unities
return self::get($id)->value ?? null;
}
- public static function get($id)
+ public static function getModel()
{
- return Unity::find($id);
- }
-
- public static function store($data)
- {
- $id = isset($data['id']) ? $data['id'] : false;
- $item = $id ? self::update($data, $id) : self::create($data);
-
- return $item->id;
- }
-
- public static function create($data)
- {
- return Unity::create($data);
- }
-
- public static function update($data, $id = false)
- {
- $id = $id ? $id : $data['id'];
- $item = self::get($id);
- $item->update($data);
-
- return $item;
- }
-
- public static function destroy($id)
- {
- return Unity::destroy($id);
+ return Unity::query();
}
}
diff --git a/app/Repositories/Shop/Variations.php b/app/Repositories/Shop/Variations.php
index 38ab7799..2dca18e0 100644
--- a/app/Repositories/Shop/Variations.php
+++ b/app/Repositories/Shop/Variations.php
@@ -20,7 +20,7 @@ class Variations
public static function autocomplete($str)
{
- $data = Variation::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
+ $data = Variation::where('name', 'LIKE', "%{$str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
$export = [];
foreach ($data as $key => $name) {
$export[] = ['value' => $key, 'text' => $name];
@@ -31,6 +31,7 @@ class Variations
public static function getOptions()
{
+ $data = [];
$variations = Variation::with(['package', 'unity'])->get();
foreach ($variations as $variation) {
$data[$variation->id] = self::getName($variation);
diff --git a/app/Rules/Password.php b/app/Rules/Password.php
index 46d05fb3..5c0fc313 100644
--- a/app/Rules/Password.php
+++ b/app/Rules/Password.php
@@ -10,23 +10,11 @@ class Password implements Rule
private $message;
- /**
- * Create a new rule instance.
- *
- * @return void
- */
public function __construct($length = 8)
{
$this->length = $length;
}
- /**
- * Determine if the validation rule passes.
- *
- * @param string $attribute
- * @param mixed $value
- * @return bool
- */
public function passes($attribute, $value)
{
$rules = [
@@ -48,11 +36,6 @@ class Password implements Rule
return true;
}
- /**
- * Get the validation error message.
- *
- * @return string
- */
public function message()
{
return $this->message;
diff --git a/app/Traits/Auth/SendsPasswordResetEmails.php b/app/Traits/Auth/SendsPasswordResetEmails.php
index 6e3b3ab0..4fee9587 100644
--- a/app/Traits/Auth/SendsPasswordResetEmails.php
+++ b/app/Traits/Auth/SendsPasswordResetEmails.php
@@ -9,63 +9,39 @@ use Illuminate\Validation\ValidationException;
trait SendsPasswordResetEmails
{
- /**
- * Display the form to request a password reset link.
- *
- * @return \Illuminate\View\View
- */
+ public function broker()
+ {
+ return Password::broker();
+ }
+
public function showLinkRequestForm()
{
return view('auth.passwords.email');
}
- /**
- * Send a reset link to the given user.
- *
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
- */
public function sendResetLinkEmail(Request $request)
{
$this->validateEmail($request);
- // We will send the password reset link to this user. Once we have attempted
- // to send the link, we will examine the response then see the message we
- // need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$this->credentials($request)
);
- return $response == Password::RESET_LINK_SENT
+ return $response === Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($request, $response)
: $this->sendResetLinkFailedResponse($request, $response);
}
- /**
- * Validate the email for the given request.
- *
- * @return void
- */
protected function validateEmail(Request $request)
{
$request->validate(['email' => 'required|email']);
}
- /**
- * Get the needed authentication credentials from the request.
- *
- * @return array
- */
protected function credentials(Request $request)
{
return $request->only('email');
}
- /**
- * Get the response for a successful password reset link.
- *
- * @param string $response
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
- */
protected function sendResetLinkResponse(Request $request, $response)
{
return $request->wantsJson()
@@ -73,14 +49,6 @@ trait SendsPasswordResetEmails
: back()->with('status', trans($response));
}
- /**
- * Get the response for a failed password reset link.
- *
- * @param string $response
- * @return \Illuminate\Http\RedirectResponse
- *
- * @throws \Illuminate\Validation\ValidationException
- */
protected function sendResetLinkFailedResponse(Request $request, $response)
{
if ($request->wantsJson()) {
@@ -93,14 +61,4 @@ trait SendsPasswordResetEmails
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
-
- /**
- * Get the broker to be used during password reset.
- *
- * @return \Illuminate\Contracts\Auth\PasswordBroker
- */
- public function broker()
- {
- return Password::broker();
- }
}
diff --git a/app/Traits/Model/HasComments.php b/app/Traits/Model/HasComments.php
index a2194fc4..441e7579 100644
--- a/app/Traits/Model/HasComments.php
+++ b/app/Traits/Model/HasComments.php
@@ -20,10 +20,9 @@ trait HasComments
public function commentAsUser(?Model $user, string $comment)
{
-
$comment = new Comment([
'comment' => $comment,
- 'is_approved' => ($user instanceof Commentator) ? ! $user->needsCommentApproval($this) : false,
+ 'is_approved' => $user instanceof Commentator ? ! $user->needsCommentApproval($this) : false,
'user_id' => is_null($user) ? null : $user->getKey(),
'commentable_id' => $this->getKey(),
'commentable_type' => get_class(),
diff --git a/app/Traits/Repository/Imageable.php b/app/Traits/Repository/Imageable.php
index 35792910..6b67458d 100644
--- a/app/Traits/Repository/Imageable.php
+++ b/app/Traits/Repository/Imageable.php
@@ -20,7 +20,7 @@ trait Imageable
{
$src = self::getThumbSrc($image, $with_undefined);
- return $src ? "
" : '';
+ return $src ? "
" : '';
}
public static function getThumbSrc($image, $with_undefined = true)
@@ -32,7 +32,7 @@ trait Imageable
{
$src = self::getPreviewSrc($image, $with_undefined);
- return $src ? "
" : '';
+ return $src ? "
" : '';
}
public static function getPreviewSrc($image, $with_undefined = true)
@@ -44,7 +44,7 @@ trait Imageable
{
$src = self::getNormalSrc($image, $with_undefined);
- return $src ? "
" : '';
+ return $src ? "
" : '';
}
public static function getNormalSrc($image, $with_undefined = true)
@@ -56,7 +56,7 @@ trait Imageable
{
$src = self::getImageSrc($image, $with_undefined);
- return $src ? "
" : '';
+ return $src ? "
" : '';
}
public static function getImageSrc($image, $with_undefined = true)
diff --git a/app/User.php b/app/User.php
index 8d52a9fe..43439d20 100644
--- a/app/User.php
+++ b/app/User.php
@@ -12,42 +12,6 @@ use Sebastienheyd\Boilerplate\Notifications\NewUser as NewUserNotification;
use Sebastienheyd\Boilerplate\Notifications\ResetPassword as ResetPasswordNotification;
use Yadahan\AuthenticationLog\AuthenticationLogable;
-/**
- * Sebastienheyd\Boilerplate\Models\User.
- *
- * @property int $id
- * @property bool $active
- * @property string $first_name
- * @property string $last_name
- * @property string $email
- * @property string $password
- * @property string $remember_token
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * @property string $deleted_at
- * @property string $last_login
- * @property-read string|false $avatar_path
- * @property-read string $avatar_url
- * @property-read mixed $name
- * @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
- * @property-read \Illuminate\Database\Eloquent\Collection|\Sebastienheyd\Boilerplate\Models\Permission[] $permissions
- * @property-read \Illuminate\Database\Eloquent\Collection|\Sebastienheyd\Boilerplate\Models\Role[] $roles
- *
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereActive($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereCreatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereDeletedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereEmail($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereFirstName($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereId($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereLastLogin($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereLastName($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User wherePassword($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereRememberToken($value)
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereRoleIs($role = '')
- * @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereUpdatedAt($value)
- *
- * @mixin \Eloquent
- */
class User extends Authenticatable
{
use AuthenticationLogable;
@@ -56,36 +20,31 @@ class User extends Authenticatable
use SoftDeletes;
use UserHasTeams;
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
protected $fillable = ['active', 'last_name', 'first_name', 'email', 'password', 'remember_token', 'last_login'];
protected $hidden = ['password', 'remember_token'];
- /**
- * The attributes that should be cast to native types.
- *
- * @var array
- */
protected $casts = [
'email_verified_at' => 'datetime',
];
public function teams()
{
- return $this->hasManyThrough('App\Models\Core\Auth\Team', 'App\Models\Core\Auth\TeamUser', 'user_id', 'id', 'id', 'team_id');
+ return $this->hasManyThrough(
+ 'App\Models\Core\Auth\Team',
+ 'App\Models\Core\Auth\TeamUser',
+ '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)
@@ -98,71 +57,35 @@ class User extends Authenticatable
return $query->where('active', 1);
}
- /**
- * Send the password reset notification.
- *
- * @param string $token
- * @return void
- */
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
- /**
- * Send notification when a new user is created.
- *
- * @param string $token
- */
public function sendNewUserNotification($token)
{
$this->notify(new NewUserNotification($token, $this));
}
- /**
- * Return last name in uppercase by default.
- *
- *
- * @return string
- */
public function getLastNameAttribute($value)
{
return mb_strtoupper($value);
}
- /**
- * Return first name with first char of every word in uppercase.
- *
- *
- * @return string
- */
public function getFirstNameAttribute($value)
{
return mb_convert_case($value, MB_CASE_TITLE);
}
- /**
- * Return a concatenation of first name and last_name if field name does not exists.
- *
- *
- * @return string
- */
public function getNameAttribute($value)
{
- if (! empty($value)) {
+ if ($value ?? false) {
return $value;
}
return $this->first_name.' '.$this->last_name;
}
- /**
- * Return last login date formatted.
- *
- * @param string $format
- * @param string $default
- * @return mixed|string
- */
public function getLastLogin($format = 'YYYY-MM-DD HH:mm:ss', $default = '')
{
if ($this->last_login === null) {
@@ -172,39 +95,24 @@ class User extends Authenticatable
return Carbon::createFromTimeString($this->last_login)->isoFormat($format);
}
- /**
- * Return role list as a string.
- *
- * @return string
- */
public function getRolesList()
{
$res = [];
foreach ($this->roles as $role) {
$res[] = __($role->display_name);
}
- if (empty($res)) {
+ if (! $res ?? true) {
return '-';
}
return implode(', ', $res);
}
- /**
- * Check if current user has an avatar.
- *
- * @return string|false
- */
public function getAvatarPathAttribute()
{
return public_path('images/avatars/'.md5($this->id.$this->email).'.jpg');
}
- /**
- * Return current user avatar uri.
- *
- * @return string
- */
public function getAvatarUrlAttribute()
{
if (is_file($this->avatar_path)) {
diff --git a/routes/Admin/Botanic/Families.php b/routes/Admin/Botanic/Families.php
index 4a6b309f..3d23508d 100644
--- a/routes/Admin/Botanic/Families.php
+++ b/routes/Admin/Botanic/Families.php
@@ -7,7 +7,5 @@ Route::prefix('Families')->name('Families.')->group(function () {
Route::post('update', 'FamilyController@update')->name('update');
Route::post('store', 'FamilyController@store')->name('store');
Route::get('edit/{id}', 'FamilyController@edit')->name('edit');
-
Route::any('exportExcel', 'FamilyController@exportExcel')->name('exportExcel');
-
});
diff --git a/routes/Admin/Botanic/Genres.php b/routes/Admin/Botanic/Genres.php
index 4bc764a9..753a30fd 100644
--- a/routes/Admin/Botanic/Genres.php
+++ b/routes/Admin/Botanic/Genres.php
@@ -7,7 +7,5 @@ Route::prefix('Genres')->name('Genres.')->group(function () {
Route::post('update', 'GenreController@update')->name('update');
Route::post('store', 'GenreController@store')->name('store');
Route::get('edit/{id}', 'GenreController@edit')->name('edit');
-
Route::any('exportExcel', 'GenreController@exportExcel')->name('exportExcel');
-
});
diff --git a/routes/Admin/Botanic/Species.php b/routes/Admin/Botanic/Species.php
index a07b601d..250ae869 100644
--- a/routes/Admin/Botanic/Species.php
+++ b/routes/Admin/Botanic/Species.php
@@ -10,7 +10,5 @@ Route::prefix('Species')->name('Species.')->group(function () {
Route::any('getSelect', 'SpecieController@getOptions')->name('getSelect');
Route::post('deleteImage', 'SpecieController@deleteImage')->name('deleteImage');
Route::any('getImages/{id?}/{can_edit?}', 'SpecieController@getImages')->name('getImages');
-
Route::any('exportExcel', 'SpecieController@exportExcel')->name('exportExcel');
-
});
diff --git a/routes/Admin/Botanic/Varieties.php b/routes/Admin/Botanic/Varieties.php
index 2ac23a19..9f7a4589 100644
--- a/routes/Admin/Botanic/Varieties.php
+++ b/routes/Admin/Botanic/Varieties.php
@@ -11,7 +11,5 @@ Route::prefix('Varieties')->name('Varieties.')->group(function () {
Route::post('getSelect', 'VarietyController@getOptionsWithSpecie')->name('getSelect');
Route::post('deleteImage', 'VarietyController@deleteImage')->name('deleteImage');
Route::any('getImages/{id?}/{can_edit?}', 'VarietyController@getImages')->name('getImages');
-
Route::any('exportExcel', 'VarietyController@exportExcel')->name('exportExcel');
-
});
diff --git a/routes/Admin/Shop/Articles.php b/routes/Admin/Shop/Articles.php
index 7d07a5b8..a46d609e 100644
--- a/routes/Admin/Shop/Articles.php
+++ b/routes/Admin/Shop/Articles.php
@@ -6,16 +6,12 @@ Route::prefix('Articles')->name('Articles.')->group(function () {
Route::delete('destroy/{id?}', 'ArticleController@destroy')->name('destroy');
Route::post('store', 'ArticleController@store')->name('store');
Route::get('edit/{id}', 'ArticleController@edit')->name('edit');
-
Route::any('getImages/{id?}', 'ArticleController@getImages')->name('getImages');
Route::post('deleteImage', 'ArticleController@deleteImage')->name('deleteImage');
-
Route::any('autocomplete/{q?}', 'ArticleController@autocomplete')->name('autocomplete');
-
Route::get('getProductDescription/{product_id?}/{model?}', 'ArticleController@getProductDescription')->name('getProductDescription');
Route::get('getProductTags/{product_id?}/{model?}', 'ArticleController@getProductTags')->name('getProductTags');
Route::get('getProductImages/{product_id?}/{model?}', 'ArticleController@getProductImages')->name('getProductImages');
Route::post('toggleVisible', 'ArticleController@toggleVisible')->name('toggleVisible');
Route::post('toggleHomepage', 'ArticleController@toggleHomepage')->name('toggleHomepage');
-
});
diff --git a/routes/Admin/Shop/CustomerAddresses.php b/routes/Admin/Shop/CustomerAddresses.php
index 2c5f0061..854a9bfc 100644
--- a/routes/Admin/Shop/CustomerAddresses.php
+++ b/routes/Admin/Shop/CustomerAddresses.php
@@ -7,5 +7,4 @@ Route::prefix('CustomerAddresses')->name('CustomerAddresses.')->group(function (
Route::post('update', 'CustomerAddressController@update')->name('update');
Route::post('store', 'CustomerAddressController@store')->name('store');
Route::get('edit/{id}', 'CustomerAddressController@edit')->name('edit');
-
});
diff --git a/routes/Admin/Shop/Customers.php b/routes/Admin/Shop/Customers.php
index a8433b10..13bd126e 100644
--- a/routes/Admin/Shop/Customers.php
+++ b/routes/Admin/Shop/Customers.php
@@ -7,5 +7,4 @@ Route::prefix('Customers')->name('Customers.')->group(function () {
Route::post('update', 'CustomerController@update')->name('update');
Route::post('store', 'CustomerController@store')->name('store');
Route::get('edit/{id}', 'CustomerController@edit')->name('edit');
-
});
diff --git a/routes/Admin/Shop/InvoiceItems.php b/routes/Admin/Shop/InvoiceItems.php
deleted file mode 100644
index e15cba85..00000000
--- a/routes/Admin/Shop/InvoiceItems.php
+++ /dev/null
@@ -1,3 +0,0 @@
-name('InvoicePayments.')->group(function () {
Route::post('update', 'InvoicePaymentController@update')->name('update');
Route::post('store', 'InvoicePaymentController@store')->name('store');
Route::get('edit/{id?}', 'InvoicePaymentController@edit')->name('edit');
-
});
diff --git a/routes/Admin/Shop/Invoices.php b/routes/Admin/Shop/Invoices.php
index a8c028d1..f103ea0c 100644
--- a/routes/Admin/Shop/Invoices.php
+++ b/routes/Admin/Shop/Invoices.php
@@ -7,5 +7,4 @@ Route::prefix('Invoices')->name('Invoices.')->group(function () {
Route::post('update', 'InvoiceController@update')->name('update');
Route::post('store', 'InvoiceController@store')->name('store');
Route::get('edit/{id}', 'InvoiceController@edit')->name('edit');
-
});
diff --git a/routes/Admin/Shop/Merchandises.php b/routes/Admin/Shop/Merchandises.php
index 240c4b64..6a863b01 100644
--- a/routes/Admin/Shop/Merchandises.php
+++ b/routes/Admin/Shop/Merchandises.php
@@ -11,7 +11,5 @@ Route::prefix('Merchandises')->name('Merchandises.')->group(function () {
Route::post('getSelect', 'MerchandiseController@getOptions')->name('getSelect');
Route::post('deleteImage', 'MerchandiseController@deleteImage')->name('deleteImage');
Route::any('getImages/{id?}/{can_edit?}', 'MerchandiseController@getImages')->name('getImages');
-
Route::any('exportExcel', 'MerchandiseController@exportExcel')->name('exportExcel');
-
});
diff --git a/routes/Admin/Shop/PriceLists.php b/routes/Admin/Shop/PriceLists.php
index e2838cda..86304758 100644
--- a/routes/Admin/Shop/PriceLists.php
+++ b/routes/Admin/Shop/PriceLists.php
@@ -7,9 +7,7 @@ Route::prefix('PriceLists')->name('PriceLists.')->group(function () {
Route::post('store', 'PriceListController@store')->name('store');
Route::delete('destroy/{id?}', 'PriceListController@destroy')->name('destroy');
Route::get('getPrices/{id?}', 'PriceListController@getPrice')->name('getPrices');
-
Route::get('modalCreate/{tariff_id?}', 'PriceListController@modalCreate')->name('modalCreate');
Route::get('modalEdit/{id?}', 'PriceListController@modalEdit')->name('modalEdit');
Route::post('storeAjax', 'PriceListController@storeAjax')->name('storeAjax');
-
});
diff --git a/routes/Admin/Shop/SaleChannels.php b/routes/Admin/Shop/SaleChannels.php
index 9e93900d..10e4a683 100644
--- a/routes/Admin/Shop/SaleChannels.php
+++ b/routes/Admin/Shop/SaleChannels.php
@@ -7,5 +7,4 @@ Route::prefix('SaleChannels')->name('SaleChannels.')->group(function () {
Route::post('update', 'SaleChannelController@update')->name('update');
Route::post('store', 'SaleChannelController@store')->name('store');
Route::get('edit/{id}', 'SaleChannelController@edit')->name('edit');
-
});
diff --git a/routes/Admin/Shop/Tariffs.php b/routes/Admin/Shop/Tariffs.php
index 0d431b77..3bf30268 100644
--- a/routes/Admin/Shop/Tariffs.php
+++ b/routes/Admin/Shop/Tariffs.php
@@ -7,7 +7,5 @@ Route::prefix('Tariffs')->name('Tariffs.')->group(function () {
Route::post('update', 'TariffController@update')->name('update');
Route::post('store', 'TariffController@store')->name('store');
Route::get('edit/{id}', 'TariffController@edit')->name('edit');
-
Route::any('autocomplete/{q?}', 'TariffController@autocomplete')->name('autocomplete');
-
});
diff --git a/routes/Admin/Shop/Variations.php b/routes/Admin/Shop/Variations.php
index bea8f56a..67ee8929 100644
--- a/routes/Admin/Shop/Variations.php
+++ b/routes/Admin/Shop/Variations.php
@@ -7,7 +7,5 @@ Route::prefix('Variations')->name('Variations.')->group(function () {
Route::post('update', 'VariationController@update')->name('update');
Route::post('store', 'VariationController@store')->name('store');
Route::get('edit/{id}', 'VariationController@edit')->name('edit');
-
Route::any('autocomplete/{q?}', 'VariationController@autocomplete')->name('autocomplete');
-
});
diff --git a/routes/Admin/Shop/route.php b/routes/Admin/Shop/route.php
index 8770d1d2..d02bd05b 100644
--- a/routes/Admin/Shop/route.php
+++ b/routes/Admin/Shop/route.php
@@ -12,7 +12,6 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
include_once __DIR__.'/DeliveryPackages.php';
include_once __DIR__.'/DeliveryTypes.php';
include_once __DIR__.'/DeliveryTypeCalculations.php';
- include_once __DIR__.'/InvoiceItems.php';
include_once __DIR__.'/InvoicePayments.php';
include_once __DIR__.'/Invoices.php';
include_once __DIR__.'/Merchandises.php';
diff --git a/routes/Botanic/route.php b/routes/Botanic/route.php
deleted file mode 100644
index e7abd0d5..00000000
--- a/routes/Botanic/route.php
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace('Botanic')->name('Botanic.')->group(function () {
-
-});
diff --git a/routes/api.php b/routes/api.php
index a713bd86..0ba24d5b 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -1,7 +1,5 @@
get('/user', function (Request $request) {
return $request->user();
});
+
*/
diff --git a/routes/web.php b/routes/web.php
index 2cab5b3b..1b952199 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -17,5 +17,4 @@ Route::get('', 'Shop\HomeController@index')->name('home');
include __DIR__.'/Admin/route.php';
include __DIR__.'/Shop/route.php';
-include __DIR__.'/Botanic/route.php';
include __DIR__.'/paybox.php';