fix devops error
This commit is contained in:
@@ -6,7 +6,7 @@ use App\Models\Shop\Tag;
|
|||||||
use App\Repositories\Shop\TagGroups;
|
use App\Repositories\Shop\TagGroups;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class addTagGroup extends Command
|
class AddTagGroup extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'addTagGroup';
|
protected $signature = 'addTagGroup';
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace App\Console\Commands;
|
|||||||
use App\Models\Shop\Category;
|
use App\Models\Shop\Category;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class untranslateShelves extends Command
|
class UntranslateShelves extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'untranslateShelves';
|
protected $signature = 'untranslateShelves';
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace App\Console\Commands;
|
|||||||
use App\Models\Shop\Tag;
|
use App\Models\Shop\Tag;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class untranslateTags extends Command
|
class UntranslateTags extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'untranslateTags';
|
protected $signature = 'untranslateTags';
|
||||||
|
|
||||||
|
|||||||
@@ -7,31 +7,13 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The Artisan commands provided by your application.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the application's command schedule.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
// $schedule->command('inspire')
|
|
||||||
// ->hourly();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the commands for the application.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function commands()
|
protected function commands()
|
||||||
{
|
{
|
||||||
$this->load(__DIR__.'/Commands');
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|||||||
@@ -30,12 +30,6 @@ class ParentDataTable extends DataTable
|
|||||||
|
|
||||||
public $stateSave = true;
|
public $stateSave = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Build DataTable class.
|
|
||||||
*
|
|
||||||
* @param mixed $query Results from query() method.
|
|
||||||
* @return \Yajra\DataTables\DataTableAbstract
|
|
||||||
*/
|
|
||||||
public function dataTable($query)
|
public function dataTable($query)
|
||||||
{
|
{
|
||||||
return $this->modifier(datatables()->eloquent($query));
|
return $this->modifier(datatables()->eloquent($query));
|
||||||
@@ -46,12 +40,6 @@ class ParentDataTable extends DataTable
|
|||||||
return $this->addButtons($datatables->setRowId('{{$id}}'));
|
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)
|
public function addButtons($datatables)
|
||||||
{
|
{
|
||||||
return $datatables->addColumn('action', $this->getHtmlButtons());
|
return $datatables->addColumn('action', $this->getHtmlButtons());
|
||||||
@@ -59,12 +47,7 @@ class ParentDataTable extends DataTable
|
|||||||
|
|
||||||
public function getHtmlButtons()
|
public function getHtmlButtons()
|
||||||
{
|
{
|
||||||
$buttons = '';
|
return self::getButtonEdit().self::getButtonDel();
|
||||||
$buttons .= self::getButtonEdit();
|
|
||||||
$buttons .= self::getButtonDel();
|
|
||||||
|
|
||||||
return $buttons;
|
|
||||||
// return view('components.datatables.buttons.row_action');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getButtonEdit()
|
public function getButtonEdit()
|
||||||
@@ -95,35 +78,23 @@ class ParentDataTable extends DataTable
|
|||||||
|
|
||||||
public static function isFilteredByField($field)
|
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)
|
public function buildQuery($model)
|
||||||
{
|
{
|
||||||
return $model->newQuery();
|
return $model->newQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional method if you want to use html builder.
|
|
||||||
*
|
|
||||||
* @return \Yajra\DataTables\Html\Builder
|
|
||||||
*/
|
|
||||||
public function html()
|
public function html()
|
||||||
{
|
{
|
||||||
return $this->buildHtml(strtolower($this->model_name).'-table');
|
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)
|
public function buildHtml($table_id = false, $selector = false)
|
||||||
{
|
{
|
||||||
$table_id = $table_id ? $table_id : strtolower($this->model_name).'-table';
|
$table_id = $table_id ? $table_id : strtolower($this->model_name).'-table';
|
||||||
@@ -135,7 +106,7 @@ class ParentDataTable extends DataTable
|
|||||||
->columns($this->getColumns())
|
->columns($this->getColumns())
|
||||||
->ajax([
|
->ajax([
|
||||||
'data' => 'function(d) { d.filters = $("'.$selector.'").serializeJSON(); }',
|
'data' => 'function(d) { d.filters = $("'.$selector.'").serializeJSON(); }',
|
||||||
'url' => isset($this->url) ? $this->url : '',
|
'url' => $this->url ?? '',
|
||||||
])
|
])
|
||||||
->dom($this->getDom())
|
->dom($this->getDom())
|
||||||
->orderBy($this->sortedColumn, $this->sortedOrder)
|
->orderBy($this->sortedColumn, $this->sortedOrder)
|
||||||
@@ -145,7 +116,6 @@ class ParentDataTable extends DataTable
|
|||||||
public function getButtons()
|
public function getButtons()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Button::make('export'),
|
|
||||||
Button::make('print'),
|
Button::make('print'),
|
||||||
Button::make('colvis'),
|
Button::make('colvis'),
|
||||||
Button::make('columnsToggle'),
|
Button::make('columnsToggle'),
|
||||||
@@ -174,12 +144,7 @@ class ParentDataTable extends DataTable
|
|||||||
|
|
||||||
public function getDom()
|
public function getDom()
|
||||||
{
|
{
|
||||||
$dom = '';
|
return 'rt'.$this->getDatatablesFooterDefault();
|
||||||
// $dom .= $this->getDatatablesHeaderDefault();
|
|
||||||
$dom .= 'rt';
|
|
||||||
$dom .= $this->getDatatablesFooterDefault();
|
|
||||||
|
|
||||||
return $dom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatatablesHeader()
|
public function getDatatablesHeader()
|
||||||
@@ -189,23 +154,7 @@ class ParentDataTable extends DataTable
|
|||||||
|
|
||||||
public function getDatatablesHeaderDefault()
|
public function getDatatablesHeaderDefault()
|
||||||
{
|
{
|
||||||
// return "<div class'row'><div class='col'></div></div>";
|
return "<'row dt-toolbar-header'<'col-lg-4'l><'col-lg-4'B><'col-lg-4 text-right add'f>>";
|
||||||
/*
|
|
||||||
|
|
||||||
$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>>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatatablesFooterDefault()
|
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>>";
|
return "<'row pt-3 dt-toolbar-footer'<'col-md-6'i><'col-md-6'p>>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get filename for export.
|
|
||||||
*/
|
|
||||||
protected function filename(): string
|
protected function filename(): string
|
||||||
{
|
{
|
||||||
return self::buildFilename($this->model_name);
|
return self::buildFilename($this->model_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get filename for export.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function buildFilename($name)
|
protected function buildFilename($name)
|
||||||
{
|
{
|
||||||
return $name.'_'.date('YmdHis');
|
return $name.'_'.date('YmdHis');
|
||||||
|
|||||||
@@ -7,47 +7,19 @@ use Throwable;
|
|||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* A list of the exception types that are not reported.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of the inputs that are never flashed for validation exceptions.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dontFlash = [
|
protected $dontFlash = [
|
||||||
'password',
|
'password',
|
||||||
'password_confirmation',
|
'password_confirmation',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Report or log an exception.
|
|
||||||
*
|
|
||||||
* @param \Exception $exception
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function report(Throwable $exception)
|
public function report(Throwable $exception)
|
||||||
{
|
{
|
||||||
parent::report($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)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Core\App;
|
|
||||||
|
|
||||||
use App\Datatables\Admin\Core\App\ApplicationsDataTable;
|
|
||||||
use App\Repositories\Core\App\Applications;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ApplicationController extends Controller
|
|
||||||
{
|
|
||||||
public function index(ApplicationsDataTable $dataTable)
|
|
||||||
{
|
|
||||||
$data = \App\Repositories\Config::init();
|
|
||||||
|
|
||||||
return $dataTable->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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Core\App;
|
|
||||||
|
|
||||||
use App\Datatables\Admin\Core\App\ApplicationModulesDataTable;
|
|
||||||
use App\Repositories\Core\App\ApplicationModules;
|
|
||||||
use App\Repositories\Core\App\Applications;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ApplicationModuleController extends Controller
|
|
||||||
{
|
|
||||||
public function index(ApplicationModulesDataTable $dataTable)
|
|
||||||
{
|
|
||||||
$data = \App\Repositories\Config::init();
|
|
||||||
|
|
||||||
return $dataTable->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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Core\App;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller as ParentController;
|
|
||||||
|
|
||||||
class Controller extends ParentController
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ use App\Datatables\Admin\Core\Auth\RolesDataTable;
|
|||||||
use App\Models\Core\App\ApplicationModule;
|
use App\Models\Core\App\ApplicationModule;
|
||||||
use App\Models\Core\Auth\Permission;
|
use App\Models\Core\Auth\Permission;
|
||||||
use App\Models\Core\Auth\Role;
|
use App\Models\Core\Auth\Role;
|
||||||
|
use App\Repositories\Config;
|
||||||
use App\Repositories\Core\Auth\Roles;
|
use App\Repositories\Core\Auth\Roles;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Yajra\DataTables\DataTables;
|
use Yajra\DataTables\DataTables;
|
||||||
@@ -14,7 +15,7 @@ class RoleController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(RolesDataTable $dataTable)
|
public function index(RolesDataTable $dataTable)
|
||||||
{
|
{
|
||||||
$data = \App\Repositories\Config::init();
|
$data = Config::init();
|
||||||
$data['modules'] = ApplicationModule::with('permissions')->get()->toArray();
|
$data['modules'] = ApplicationModule::with('permissions')->get()->toArray();
|
||||||
|
|
||||||
return $dataTable->render('admin.Core.Auth.Role.index', $data);
|
return $dataTable->render('admin.Core.Auth.Role.index', $data);
|
||||||
@@ -29,7 +30,7 @@ class RoleController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$data = \App\Repositories\Config::init();
|
$data = Config::init();
|
||||||
|
|
||||||
return view('Admin.Core.Auth.Role.create', $data);
|
return view('Admin.Core.Auth.Role.create', $data);
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ class RoleController extends Controller
|
|||||||
public function edit(Request $request, $id = false)
|
public function edit(Request $request, $id = false)
|
||||||
{
|
{
|
||||||
$id = $id ? $id : $request->input('id');
|
$id = $id ? $id : $request->input('id');
|
||||||
$data = \App\Repositories\Config::init();
|
$data = Config::init();
|
||||||
$data['role'] = Roles::getWithPermissions($id);
|
$data['role'] = Roles::getWithPermissions($id);
|
||||||
$data['modules'] = ApplicationModule::with('permissions')->get()->toArray();
|
$data['modules'] = ApplicationModule::with('permissions')->get()->toArray();
|
||||||
|
|
||||||
@@ -72,9 +73,6 @@ class RoleController extends Controller
|
|||||||
'id' => $permission->id,
|
'id' => $permission->id,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// Debug::fdump($data);
|
|
||||||
// Debug::fdump($permissions);
|
|
||||||
// exit;
|
|
||||||
$data['permissions'] = $data;
|
$data['permissions'] = $data;
|
||||||
|
|
||||||
return view('Admin.Core.Auth.Role.manage', $data);
|
return view('Admin.Core.Auth.Role.manage', $data);
|
||||||
@@ -94,7 +92,7 @@ class RoleController extends Controller
|
|||||||
|
|
||||||
public function toggleActive(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class TeamController extends Controller
|
|||||||
$request->replace($input);
|
$request->replace($input);
|
||||||
|
|
||||||
$this->validate(
|
$this->validate(
|
||||||
$request, [
|
$request,
|
||||||
|
[
|
||||||
'name' => 'required|unique:teams,name',
|
'name' => 'required|unique:teams,name',
|
||||||
'display_name' => 'required',
|
'display_name' => 'required',
|
||||||
'description' => 'required',
|
'description' => 'required',
|
||||||
@@ -55,7 +56,8 @@ class TeamController extends Controller
|
|||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$this->validate(
|
$this->validate(
|
||||||
$request, [
|
$request,
|
||||||
|
[
|
||||||
'display_name' => 'required',
|
'display_name' => 'required',
|
||||||
'description' => 'required',
|
'description' => 'required',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin\Core\Auth;
|
|||||||
|
|
||||||
use App\Datatables\Admin\Core\Auth\UsersDataTable;
|
use App\Datatables\Admin\Core\Auth\UsersDataTable;
|
||||||
use App\Models\Core\Auth\User;
|
use App\Models\Core\Auth\User;
|
||||||
|
use App\Repositories\Config;
|
||||||
use App\Repositories\Core\Auth\Users;
|
use App\Repositories\Core\Auth\Users;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -15,14 +16,16 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(UsersDataTable $dataTable)
|
public function index(UsersDataTable $dataTable)
|
||||||
{
|
{
|
||||||
$data = \App\Repositories\Config::init();
|
$data = Config::init();
|
||||||
|
|
||||||
return $dataTable->render('admin.Core.Auth.User.index', $data);
|
return $dataTable->render('admin.Core.Auth.User.index', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modalCreate()
|
public function modalCreate()
|
||||||
{
|
{
|
||||||
$data['roles'] = Users::getRolesToEdit();
|
$data = [
|
||||||
|
'roles' => Users::getRolesToEdit(),
|
||||||
|
];
|
||||||
|
|
||||||
return view('Admin.Core.Auth.User.modal', $data);
|
return view('Admin.Core.Auth.User.modal', $data);
|
||||||
}
|
}
|
||||||
@@ -55,13 +58,6 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function store(Request $request)
|
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();
|
$input = $request->all();
|
||||||
if (empty($input['password'])) {
|
if (empty($input['password'])) {
|
||||||
unset($input['password']);
|
unset($input['password']);
|
||||||
@@ -74,7 +70,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = \App\Repositories\Config::init();
|
$data = Config::init();
|
||||||
$data['roles'] = Users::getRolesToEdit();
|
$data['roles'] = Users::getRolesToEdit();
|
||||||
$data['user'] = Users::get($id);
|
$data['user'] = Users::get($id);
|
||||||
|
|
||||||
@@ -95,13 +91,11 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function firstLoginPost(Request $request)
|
public function firstLoginPost(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate(
|
$this->validate($request, [
|
||||||
$request, [
|
|
||||||
'token' => 'required',
|
'token' => 'required',
|
||||||
'password' => 'required|min:8',
|
'password' => 'required|min:8',
|
||||||
'password_confirmation' => 'required|same:password',
|
'password_confirmation' => 'required|same:password',
|
||||||
]
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
$user = User::where(['remember_token' => $request->input('token')])->first();
|
$user = User::where(['remember_token' => $request->input('token')])->first();
|
||||||
|
|
||||||
@@ -128,19 +122,18 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function profilePost(Request $request)
|
public function profilePost(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate(
|
$this->validate($request, [
|
||||||
$request, [
|
|
||||||
'avatar' => 'mimes:jpeg,png|max:10000',
|
'avatar' => 'mimes:jpeg,png|max:10000',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'password_confirmation' => 'same:password',
|
'password_confirmation' => 'same:password',
|
||||||
]
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
$avatar = $request->file('avatar');
|
$avatar = $request->file('avatar');
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
$file = $avatar->isValid();
|
||||||
|
|
||||||
if ($avatar && $file = $avatar->isValid()) {
|
if ($avatar && $file) {
|
||||||
$destinationPath = dirname($user->avatar_path);
|
$destinationPath = dirname($user->avatar_path);
|
||||||
if (! is_dir($destinationPath)) {
|
if (! is_dir($destinationPath)) {
|
||||||
mkdir($destinationPath, 0766, true);
|
mkdir($destinationPath, 0766, true);
|
||||||
@@ -181,7 +174,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function toggleActive(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,24 +67,32 @@ class ArticleController extends Controller
|
|||||||
return Articles::destroy($id);
|
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);
|
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);
|
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 = [
|
||||||
$data['no_popup'] = false;
|
'article' => [
|
||||||
|
'product_id' => $productId,
|
||||||
|
],
|
||||||
|
'no_popup' => false,
|
||||||
|
];
|
||||||
|
|
||||||
return view('Admin.Shop.Articles.partials.product.images', $data);
|
return view('Admin.Shop.Articles.partials.product.images', $data);
|
||||||
}
|
}
|
||||||
@@ -92,7 +100,9 @@ class ArticleController extends Controller
|
|||||||
public function getImages(Request $request, $id = false)
|
public function getImages(Request $request, $id = false)
|
||||||
{
|
{
|
||||||
$id = $id ? $id : $request->input('id');
|
$id = $id ? $id : $request->input('id');
|
||||||
$data['images'] = Articles::getImages($id);
|
$data = [
|
||||||
|
'images' => Articles::getImages($id),
|
||||||
|
];
|
||||||
|
|
||||||
return view('components.uploader.mini-gallery-items', $data);
|
return view('components.uploader.mini-gallery-items', $data);
|
||||||
}
|
}
|
||||||
@@ -107,14 +117,14 @@ class ArticleController extends Controller
|
|||||||
|
|
||||||
public function toggleVisible(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleHomepage(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,14 +80,14 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
public function toggleVisible(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleHomepage(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class DeliveryController extends Controller
|
|||||||
|
|
||||||
public function toggleActive(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ class InvoiceController extends Controller
|
|||||||
{
|
{
|
||||||
$data = Invoices::init();
|
$data = Invoices::init();
|
||||||
$data['invoice'] = Invoices::getFull($id)->toArray();
|
$data['invoice'] = Invoices::getFull($id)->toArray();
|
||||||
/*
|
|
||||||
$model = new InvoicePaymentsDataTable();
|
|
||||||
$data['invoice_payments'] = $model->html();
|
|
||||||
*/
|
|
||||||
// dump($data);
|
|
||||||
|
|
||||||
return view('Admin.Shop.Invoices.edit', $data);
|
return view('Admin.Shop.Invoices.edit', $data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Shop;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\InvoiceItem;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class InvoiceItemController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for creating a new resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the specified resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function show(InvoiceItem $invoiceItem)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for editing the specified resource.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function edit(InvoiceItem $invoiceItem)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function update(Request $request, InvoiceItem $invoiceItem)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function destroy(InvoiceItem $invoiceItem)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -83,7 +83,7 @@ class OfferController extends Controller
|
|||||||
|
|
||||||
public function toggleActive(Request $request)
|
public function toggleActive(Request $request)
|
||||||
{
|
{
|
||||||
$data = Offers::toggle_active($request->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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ class PackageController extends Controller
|
|||||||
return view('Admin.Shop.Packages.edit', $data);
|
return view('Admin.Shop.Packages.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
return Packages::destroy($id);
|
return Packages::destroy($id);
|
||||||
|
|||||||
@@ -45,11 +45,6 @@ class TagController extends Controller
|
|||||||
return view('Admin.Shop.Tags.edit', $data);
|
return view('Admin.Shop.Tags.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
return Tags::destroy($id);
|
return Tags::destroy($id);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class TagGroupController extends Controller
|
|||||||
|
|
||||||
public function toggleVisible(Request $request)
|
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]);
|
return response()->json(['error' => 0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,14 @@ namespace App\Http\Controllers\Shop;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Shop\Articles;
|
use App\Repositories\Shop\Articles;
|
||||||
use App\Repositories\Shop\Categories;
|
|
||||||
|
|
||||||
class ArticleController extends Controller
|
class ArticleController extends Controller
|
||||||
{
|
{
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$data['article'] = Articles::getArticleToSell($id);
|
$data['article'] = Articles::getArticleToSell($id);
|
||||||
// $data['breadcrumb'] = Categories::getAncestorsByCategory($category_id);
|
|
||||||
$data['offers2'] = Articles::getSiblings($id)->toArray();
|
$data['offers2'] = Articles::getSiblings($id)->toArray();
|
||||||
|
|
||||||
// dump($data);
|
|
||||||
// exit;
|
|
||||||
return view('Shop.Articles.show', $data);
|
return view('Shop.Articles.show', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ class ForgotPasswordController extends Controller
|
|||||||
{
|
{
|
||||||
use SendsPasswordResetEmails;
|
use SendsPasswordResetEmails;
|
||||||
|
|
||||||
protected function guard()
|
|
||||||
{
|
|
||||||
return Auth::guard('customer');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function broker()
|
public function broker()
|
||||||
{
|
{
|
||||||
return Password::broker('customers');
|
return Password::broker('customers');
|
||||||
@@ -25,4 +20,9 @@ class ForgotPasswordController extends Controller
|
|||||||
{
|
{
|
||||||
return view('Shop.auth.passwords.email');
|
return view('Shop.auth.passwords.email');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function guard()
|
||||||
|
{
|
||||||
|
return Auth::guard('customer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ class LoginController extends Controller
|
|||||||
// $this->middleware('guest')->except('logout');
|
// $this->middleware('guest')->except('logout');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function guard()
|
|
||||||
{
|
|
||||||
return Auth::guard('customer');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showLoginForm()
|
public function showLoginForm()
|
||||||
{
|
{
|
||||||
return view('Shop.auth.login');
|
return view('Shop.auth.login');
|
||||||
@@ -38,10 +33,12 @@ class LoginController extends Controller
|
|||||||
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
|
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
|
||||||
$request->session()->regenerate();
|
$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)
|
public function logout(Request $request)
|
||||||
@@ -57,4 +54,10 @@ class LoginController extends Controller
|
|||||||
{
|
{
|
||||||
return 'email';
|
return 'email';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function guard()
|
||||||
|
{
|
||||||
|
return Auth::guard('customer');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,29 +5,15 @@ namespace App\Http\Controllers\Shop\Auth;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Shop\CustomerAddresses;
|
use App\Repositories\Shop\CustomerAddresses;
|
||||||
use App\Repositories\Shop\Customers;
|
use App\Repositories\Shop\Customers;
|
||||||
use Illuminate\Auth\Events\Registered;
|
|
||||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
// use RegistersUsers;
|
|
||||||
|
|
||||||
protected $redirectTo;
|
protected $redirectTo;
|
||||||
|
|
||||||
protected function guard()
|
|
||||||
{
|
|
||||||
return Auth::guard('customer');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function redirectTo()
|
|
||||||
{
|
|
||||||
return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showRegistrationForm()
|
public function showRegistrationForm()
|
||||||
{
|
{
|
||||||
return view('Shop.auth.register');
|
return view('Shop.auth.register');
|
||||||
@@ -35,16 +21,12 @@ class RegisterController extends Controller
|
|||||||
|
|
||||||
public function register(Request $request)
|
public function register(Request $request)
|
||||||
{
|
{
|
||||||
dump('ici');
|
|
||||||
exit;
|
|
||||||
// event(new Registered($user = $this->create($request->all())));
|
|
||||||
$user = $this->create($request->all());
|
$user = $this->create($request->all());
|
||||||
dump($user);
|
|
||||||
exit;
|
|
||||||
|
|
||||||
$this->guard()->login($user);
|
$this->guard()->login($user);
|
||||||
|
$response = $this->registered($request, $user);
|
||||||
|
|
||||||
if ($response = $this->registered($request, $user)) {
|
if ($response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,14 +35,6 @@ class RegisterController extends Controller
|
|||||||
: redirect($this->redirectPath());
|
: redirect($this->redirectPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function create(array $data)
|
|
||||||
{
|
|
||||||
$user = Customers::create($data);
|
|
||||||
CustomerAddresses::add($user->id, $data);
|
|
||||||
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function emailVerify()
|
public function emailVerify()
|
||||||
{
|
{
|
||||||
if (Auth::user()->hasVerifiedEmail()) {
|
if (Auth::user()->hasVerifiedEmail()) {
|
||||||
@@ -83,4 +57,23 @@ class RegisterController extends Controller
|
|||||||
|
|
||||||
return back()->with('message', 'Verification link sent!');
|
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'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class ResetPasswordController extends Controller
|
|||||||
|
|
||||||
protected $redirectTo = '/';
|
protected $redirectTo = '/';
|
||||||
|
|
||||||
|
public function broker()
|
||||||
|
{
|
||||||
|
return Password::broker('customers');
|
||||||
|
}
|
||||||
|
|
||||||
public function showResetForm(Request $request, $token = null)
|
public function showResetForm(Request $request, $token = null)
|
||||||
{
|
{
|
||||||
return view('Shop.auth.passwords.reset')->with([
|
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()
|
protected function guard()
|
||||||
{
|
{
|
||||||
return Auth::guard('customer');
|
return Auth::guard('customer');
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ class InvoiceController extends Controller
|
|||||||
\Debugbar::disable();
|
\Debugbar::disable();
|
||||||
$data['invoice'] = Invoices::getByUUID($uuid);
|
$data['invoice'] = Invoices::getByUUID($uuid);
|
||||||
$filename = 'invoice-'.$uuid.'.pdf';
|
$filename = 'invoice-'.$uuid.'.pdf';
|
||||||
$html = view('Shop.Invoices.pdf', $data)->toHtml();
|
|
||||||
|
|
||||||
// $html = '<h1>Hello world!</h1>';
|
|
||||||
// return PDF::convertHTML($html);
|
|
||||||
// return view('Shop.Invoices.pdf', $data);
|
|
||||||
return PDF::view('Shop.Invoices.pdf', $data, $filename);
|
return PDF::view('Shop.Invoices.pdf', $data, $filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ class OrderController extends Controller
|
|||||||
|
|
||||||
public function pdf($uuid)
|
public function pdf($uuid)
|
||||||
{
|
{
|
||||||
$data['order'] = Orders::getByUUID($uuid);
|
$data = [
|
||||||
|
'order' => Orders::getByUUID($uuid),
|
||||||
|
];
|
||||||
|
|
||||||
return view('Shop.Orders.pdf', $data);
|
return view('Shop.Orders.pdf', $data);
|
||||||
}
|
}
|
||||||
@@ -45,15 +47,14 @@ class OrderController extends Controller
|
|||||||
$data = [
|
$data = [
|
||||||
'customer' => $customer ? $customer->toArray() : false,
|
'customer' => $customer ? $customer->toArray() : false,
|
||||||
'basket' => Baskets::getBasketTotal(),
|
'basket' => Baskets::getBasketTotal(),
|
||||||
// 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
|
||||||
'deliveries' => $deliveries ? $deliveries->toArray() : [],
|
'deliveries' => $deliveries ? $deliveries->toArray() : [],
|
||||||
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('Shop.Orders.order', $data);
|
return view('Shop.Orders.order', $data);
|
||||||
} else {
|
|
||||||
return redirect()->route('home');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect()->route('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
@@ -64,18 +65,14 @@ class OrderController extends Controller
|
|||||||
$data['basket'] = Baskets::getBasketSummary($data['sale_channel_id'], $data['delivery_type_id'] ?? false);
|
$data['basket'] = Baskets::getBasketSummary($data['sale_channel_id'], $data['delivery_type_id'] ?? false);
|
||||||
$order = Orders::saveOrder($data);
|
$order = Orders::saveOrder($data);
|
||||||
if ($order) {
|
if ($order) {
|
||||||
if ($data['payment_type'] == '1') {
|
if ($data['payment_type'] === '1') {
|
||||||
return Paybox::makeAuthorizationRequest($order);
|
return Paybox::makeAuthorizationRequest($order);
|
||||||
} else {
|
}
|
||||||
|
OrderMails::sendOrderConfirmed($order->id);
|
||||||
return redirect()->route('Shop.Orders.confirmed');
|
return redirect()->route('Shop.Orders.confirmed');
|
||||||
}
|
}
|
||||||
if ($ret) {
|
|
||||||
OrderMails::sendOrderConfirmed($order->id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return view('Shop.Orders.order');
|
return view('Shop.Orders.order');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function confirmed()
|
public function confirmed()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
|||||||
|
|
||||||
class Authenticate extends 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)
|
protected function redirectTo($request)
|
||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
if (! $request->expectsJson()) {
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
|||||||
|
|
||||||
class CheckForMaintenanceMode extends Middleware
|
class CheckForMaintenanceMode extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The URIs that should be reachable while maintenance mode is enabled.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
|||||||
|
|
||||||
class EncryptCookies extends Middleware
|
class EncryptCookies extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The names of the cookies that should not be encrypted.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,8 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
|||||||
|
|
||||||
class VerifyCsrfToken extends Middleware
|
class VerifyCsrfToken extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $addHttpCookie = true;
|
protected $addHttpCookie = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* The URIs that should be excluded from CSRF verification.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ class Acheminement extends TemplateMailable
|
|||||||
{
|
{
|
||||||
use MailCustomers, Queueable, SerializesModels;
|
use MailCustomers, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected static $templateModelClass = MailTemplate::class;
|
|
||||||
|
|
||||||
public $email;
|
public $email;
|
||||||
|
|
||||||
public $nom;
|
public $nom;
|
||||||
@@ -43,6 +41,8 @@ class Acheminement extends TemplateMailable
|
|||||||
|
|
||||||
public $mode_livraison;
|
public $mode_livraison;
|
||||||
|
|
||||||
|
protected static $templateModelClass = MailTemplate::class;
|
||||||
|
|
||||||
public function __construct($order)
|
public function __construct($order)
|
||||||
{
|
{
|
||||||
$this->prenom = $order->customer->first_name;
|
$this->prenom = $order->customer->first_name;
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class Bienvenue extends TemplateMailable
|
|||||||
{
|
{
|
||||||
use MailCustomers, Queueable, SerializesModels;
|
use MailCustomers, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected static $templateModelClass = MailTemplate::class;
|
|
||||||
|
|
||||||
public $email;
|
public $email;
|
||||||
|
|
||||||
public $nom;
|
public $nom;
|
||||||
@@ -24,6 +22,8 @@ class Bienvenue extends TemplateMailable
|
|||||||
|
|
||||||
public $subject;
|
public $subject;
|
||||||
|
|
||||||
|
protected static $templateModelClass = MailTemplate::class;
|
||||||
|
|
||||||
public function __construct($user, $subject = '')
|
public function __construct($user, $subject = '')
|
||||||
{
|
{
|
||||||
$this->prenom = $user->first_name;
|
$this->prenom = $user->first_name;
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class ConfirmationCommande extends TemplateMailable
|
|||||||
{
|
{
|
||||||
use MailCustomers, Queueable, SerializesModels;
|
use MailCustomers, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected static $templateModelClass = MailTemplate::class;
|
|
||||||
|
|
||||||
public $email;
|
public $email;
|
||||||
|
|
||||||
public $nom;
|
public $nom;
|
||||||
@@ -40,6 +38,8 @@ class ConfirmationCommande extends TemplateMailable
|
|||||||
|
|
||||||
public $livraison_ville;
|
public $livraison_ville;
|
||||||
|
|
||||||
|
protected static $templateModelClass = MailTemplate::class;
|
||||||
|
|
||||||
public function __construct($order)
|
public function __construct($order)
|
||||||
{
|
{
|
||||||
$this->prenom = $order->customer->first_name;
|
$this->prenom = $order->customer->first_name;
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class Preparation extends TemplateMailable
|
|||||||
{
|
{
|
||||||
use MailCustomers, Queueable, SerializesModels;
|
use MailCustomers, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected static $templateModelClass = MailTemplate::class;
|
|
||||||
|
|
||||||
public $email;
|
public $email;
|
||||||
|
|
||||||
public $nom;
|
public $nom;
|
||||||
@@ -24,6 +22,8 @@ class Preparation extends TemplateMailable
|
|||||||
|
|
||||||
public $subject;
|
public $subject;
|
||||||
|
|
||||||
|
protected static $templateModelClass = MailTemplate::class;
|
||||||
|
|
||||||
public function __construct($order)
|
public function __construct($order)
|
||||||
{
|
{
|
||||||
$this->prenom = $order->customer->first_name;
|
$this->prenom = $order->customer->first_name;
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Core\App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Application extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'system';
|
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function pages()
|
|
||||||
{
|
|
||||||
return $this->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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Core\App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ApplicationClient extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'system';
|
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
|
|
||||||
protected $table = 'application_clients';
|
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function application()
|
|
||||||
{
|
|
||||||
return $this->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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Core\App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ApplicationModule extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'system';
|
|
||||||
|
|
||||||
protected $table = 'application_modules';
|
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function application()
|
|
||||||
{
|
|
||||||
return $this->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Core\App;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ApplicationPage extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'system';
|
|
||||||
|
|
||||||
protected $table = 'application_pages';
|
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function application()
|
|
||||||
{
|
|
||||||
return $this->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,13 +9,13 @@ class Team extends LaratrustTeam
|
|||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $connection = 'mysql';
|
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
return $this->hasMany(\App\Models\Core\Auth\User::class);
|
return $this->hasMany(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeActive($query)
|
public function scopeActive($query)
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Core\Auth;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class UserClient extends Model
|
|
||||||
{
|
|
||||||
protected $connection = 'system';
|
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function client()
|
|
||||||
{
|
|
||||||
return $this->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,14 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class UserStatus extends Model
|
class UserStatus extends Model
|
||||||
{
|
{
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $connection = 'mysql';
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $table = 'user_statuses';
|
protected $table = 'user_statuses';
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function scopeByName($query, $name)
|
public function scopeByName($query, $name)
|
||||||
{
|
{
|
||||||
return $query->where('name', $name);
|
return $query->where('name', $name);
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class UserStatusTeam extends Model
|
class UserStatusTeam extends Model
|
||||||
{
|
{
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $connection = 'mysql';
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $table = 'user_status_teams';
|
protected $table = 'user_status_teams';
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public function user_status()
|
public function user_status()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\Core\Auth\UserStatus::class);
|
return $this->belongsTo(UserStatus::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function team()
|
public function team()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\Core\Auth\Team::class);
|
return $this->belongsTo(Team::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeByUserStatus($query, $id)
|
public function scopeByUserStatus($query, $id)
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ class Category extends parentCategory
|
|||||||
{
|
{
|
||||||
use CascadeDelete, SoftDeletes, Taggable, Userstamps;
|
use CascadeDelete, SoftDeletes, Taggable, Userstamps;
|
||||||
|
|
||||||
|
public $translatable = [];
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $table = 'categories';
|
protected $table = 'categories';
|
||||||
|
|
||||||
public $translatable = [];
|
|
||||||
|
|
||||||
protected $cascadeDeleteMorph = ['Articles'];
|
protected $cascadeDeleteMorph = ['Articles'];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
|||||||
@@ -50,9 +50,7 @@ class Customer extends Authenticatable
|
|||||||
|
|
||||||
public function deliveries()
|
public function deliveries()
|
||||||
{
|
{
|
||||||
return $this->hasManyDeepFromRelations(
|
return $this->hasManyDeepFromRelations($this->sale_channels(), (new SaleChannel())->deliveries())
|
||||||
$this->sale_channels(),
|
|
||||||
(new SaleChannel())->deliveries())
|
|
||||||
->whereNull('shop_customer_sale_channels.deleted_at');
|
->whereNull('shop_customer_sale_channels.deleted_at');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ class PriceListValue extends Model
|
|||||||
|
|
||||||
public function tariff()
|
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\Tariff' => 'tariff_id',
|
||||||
'App\Models\Shop\PriceList' => 'price_list_id',
|
'App\Models\Shop\PriceList' => 'price_list_id',
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ use Rinvex\Tags\Models\Tag as parentTag;
|
|||||||
|
|
||||||
class Tag extends parentTag
|
class Tag extends parentTag
|
||||||
{
|
{
|
||||||
|
public $translatable = [];
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
@@ -19,8 +21,6 @@ class Tag extends parentTag
|
|||||||
'tag_group_id',
|
'tag_group_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
public $translatable = [];
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public function offers()
|
public function offers()
|
||||||
{
|
{
|
||||||
@@ -69,9 +69,11 @@ class Tag extends parentTag
|
|||||||
|
|
||||||
public function scopeWithCountArticlesByCategory($query, $category_id)
|
public function scopeWithCountArticlesByCategory($query, $category_id)
|
||||||
{
|
{
|
||||||
return $query->withCount(['articles' => function ($query) use ($category_id) {
|
return $query->withCount([
|
||||||
|
'articles' => function ($query) use ($category_id) {
|
||||||
$query->byCategoryParent($category_id);
|
$query->byCategoryParent($category_id);
|
||||||
}]);
|
},
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeById($query, $id)
|
public function scopeById($query, $id)
|
||||||
|
|||||||
@@ -5,31 +5,20 @@ namespace App\Notifications;
|
|||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class NewUser extends Notification
|
class NewUser extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
return ['mail'];
|
return ['mail'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the mail representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
||||||
*/
|
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
$currentUser = \Auth::user();
|
$currentUser = Auth::user();
|
||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('boilerplate::notifications.email')
|
->markdown('boilerplate::notifications.email')
|
||||||
@@ -48,16 +37,9 @@ class NewUser extends Notification
|
|||||||
->line(__('boilerplate::notifications.newuser.outro'));
|
->line(__('boilerplate::notifications.newuser.outro'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ use Illuminate\Notifications\Messages\MailMessage;
|
|||||||
|
|
||||||
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
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)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
|
|||||||
@@ -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)
|
protected function buildMailMessage($url)
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage())
|
||||||
->markdown('boilerplate::notifications.email')
|
->markdown('boilerplate::notifications.email')
|
||||||
->subject(__('Verify Email Address'))
|
->subject(__('Verify Email Address'))
|
||||||
->line(__('Please click the button below to verify your email address.'))
|
->line(__('Please click the button below to verify your email address.'))
|
||||||
|
|||||||
@@ -9,21 +9,6 @@ use Illuminate\Support\ServiceProvider;
|
|||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Register any application services.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap any application services.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
|
|||||||
@@ -6,24 +6,12 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
|
|||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The policy mappings for the application.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Register any authentication / authorization services.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
$this->registerPolicies();
|
||||||
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,30 +5,12 @@ namespace App\Providers;
|
|||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Event;
|
|
||||||
|
|
||||||
class EventServiceProvider extends ServiceProvider
|
class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The event listener mappings for the application.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
Registered::class => [
|
Registered::class => [
|
||||||
SendEmailVerificationNotification::class,
|
SendEmailVerificationNotification::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Register any events for your application.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,55 +7,16 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
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';
|
public const HOME = '/home';
|
||||||
|
|
||||||
/**
|
protected $namespace = 'App\Http\Controllers';
|
||||||
* Define your route model bindings, pattern filters, etc.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the routes for the application.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function map()
|
public function map()
|
||||||
{
|
{
|
||||||
$this->mapApiRoutes();
|
$this->mapApiRoutes();
|
||||||
|
|
||||||
$this->mapWebRoutes();
|
$this->mapWebRoutes();
|
||||||
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "web" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes all receive session state, CSRF protection, etc.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function mapWebRoutes()
|
protected function mapWebRoutes()
|
||||||
{
|
{
|
||||||
Route::middleware('web')
|
Route::middleware('web')
|
||||||
@@ -63,13 +24,6 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
->group(base_path('routes/web.php'));
|
->group(base_path('routes/web.php'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "api" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes are typically stateless.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function mapApiRoutes()
|
protected function mapApiRoutes()
|
||||||
{
|
{
|
||||||
Route::prefix('api')
|
Route::prefix('api')
|
||||||
|
|||||||
@@ -4,62 +4,20 @@ namespace App\Repositories\Botanic;
|
|||||||
|
|
||||||
use App\Exports\Botanic\FamiliesExport;
|
use App\Exports\Botanic\FamiliesExport;
|
||||||
use App\Models\Botanic\Family;
|
use App\Models\Botanic\Family;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Yajra\DataTables\DataTables;
|
|
||||||
|
|
||||||
class Families
|
class Families
|
||||||
{
|
{
|
||||||
public static function getDatatable()
|
use Basic;
|
||||||
{
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function exportExcel()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,53 +4,20 @@ namespace App\Repositories\Botanic;
|
|||||||
|
|
||||||
use App\Exports\Botanic\GenresExport;
|
use App\Exports\Botanic\GenresExport;
|
||||||
use App\Models\Botanic\Genre;
|
use App\Models\Botanic\Genre;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class Genres
|
class Genres
|
||||||
{
|
{
|
||||||
public static function getOptions()
|
use Basic;
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function exportExcel()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,22 +5,13 @@ namespace App\Repositories\Botanic;
|
|||||||
use App\Exports\Botanic\SpeciesExport;
|
use App\Exports\Botanic\SpeciesExport;
|
||||||
use App\Models\Botanic\Specie;
|
use App\Models\Botanic\Specie;
|
||||||
use App\Repositories\Core\Tag;
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use App\Traits\Repository\Imageable;
|
use App\Traits\Repository\Imageable;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class Species
|
class Species
|
||||||
{
|
{
|
||||||
use Imageable;
|
use Basic, Imageable;
|
||||||
|
|
||||||
public static function getOptions()
|
|
||||||
{
|
|
||||||
return Specie::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAll()
|
|
||||||
{
|
|
||||||
return Specie::orderBy('name', 'asc')->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDescription($id)
|
public static function getDescription($id)
|
||||||
{
|
{
|
||||||
@@ -66,30 +57,6 @@ class Species
|
|||||||
return $specie;
|
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)
|
public static function storeTags($specie, $tags)
|
||||||
{
|
{
|
||||||
return Tag::storeTags($specie, $tags);
|
return Tag::storeTags($specie, $tags);
|
||||||
@@ -97,6 +64,11 @@ class Species
|
|||||||
|
|
||||||
public static function exportExcel()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,13 @@ namespace App\Repositories\Botanic;
|
|||||||
use App\Exports\Botanic\VarietiesExport;
|
use App\Exports\Botanic\VarietiesExport;
|
||||||
use App\Models\Botanic\Variety;
|
use App\Models\Botanic\Variety;
|
||||||
use App\Repositories\Core\Tag;
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use App\Traits\Repository\Imageable;
|
use App\Traits\Repository\Imageable;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class Varieties
|
class Varieties
|
||||||
{
|
{
|
||||||
use Imageable;
|
use Basic, Imageable;
|
||||||
|
|
||||||
public static function getOptions()
|
|
||||||
{
|
|
||||||
return Variety::orderBy('name')->get()->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getOptionsWithSpecie()
|
public static function getOptionsWithSpecie()
|
||||||
{
|
{
|
||||||
@@ -29,11 +25,6 @@ class Varieties
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAll()
|
|
||||||
{
|
|
||||||
return Variety::orderBy('name', 'asc')->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDescription($id)
|
public static function getDescription($id)
|
||||||
{
|
{
|
||||||
return self::get($id)->description;
|
return self::get($id)->description;
|
||||||
@@ -65,8 +56,8 @@ class Varieties
|
|||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
{
|
{
|
||||||
$images = isset($data['images']) ? $data['images'] : false;
|
$images = $data['images'] ?? false;
|
||||||
$tags = isset($data['tags']) ? $data['tags'] : false;
|
$tags = $data['tags'] ?? false;
|
||||||
unset($data['images']);
|
unset($data['images']);
|
||||||
unset($data['tags']);
|
unset($data['tags']);
|
||||||
$variety = self::store($data);
|
$variety = self::store($data);
|
||||||
@@ -76,30 +67,6 @@ class Varieties
|
|||||||
return $variety;
|
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)
|
public static function storeTags($variety, $tags)
|
||||||
{
|
{
|
||||||
return Tag::storeTags($variety, $tags);
|
return Tag::storeTags($variety, $tags);
|
||||||
@@ -107,6 +74,11 @@ class Varieties
|
|||||||
|
|
||||||
public static function exportExcel()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,23 @@ class Cities
|
|||||||
{
|
{
|
||||||
public static function getCitiesByName($query)
|
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)
|
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)
|
public static function getCPByCity($id)
|
||||||
{
|
{
|
||||||
$ville = self::get($id);
|
$ville = self::get($id);
|
||||||
$codes = explode('-', $ville->code_postal);
|
|
||||||
|
|
||||||
return $codes;
|
return explode('-', $ville->code_postal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNomByCity($id)
|
public static function getNomByCity($id)
|
||||||
@@ -39,24 +42,15 @@ class Cities
|
|||||||
|
|
||||||
public static function getCoords($adresse)
|
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();
|
$geocode = app('geocoder')->geocode($adresse)->get();
|
||||||
// dump($geocode);
|
|
||||||
if (! count($geocode)) {
|
if (! count($geocode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// dump($geocode);
|
|
||||||
$res = $geocode[0]->getCoordinates()->toArray();
|
$res = $geocode[0]->getCoordinates()->toArray();
|
||||||
// dump($res);
|
|
||||||
$latitude = $res[0];
|
$latitude = $res[0];
|
||||||
$longitude = $res[1];
|
$longitude = $res[1];
|
||||||
|
|
||||||
// dump($latitude);
|
|
||||||
// dump($longitude);
|
|
||||||
return ['latitude' => $latitude, 'longitude' => $longitude];
|
return ['latitude' => $latitude, 'longitude' => $longitude];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCoordsByCity($id)
|
public static function getCoordsByCity($id)
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core\App;
|
|
||||||
|
|
||||||
use App\Models\Core\App\ApplicationClient;
|
|
||||||
use App\Repositories\Clients;
|
|
||||||
|
|
||||||
class ApplicationClients
|
|
||||||
{
|
|
||||||
public static function associate($client_id, $applications_list)
|
|
||||||
{
|
|
||||||
$applications_existing = self::getApplicationsByClient($client_id);
|
|
||||||
$applications_list = is_array($applications_list) ? $applications_list : [];
|
|
||||||
|
|
||||||
if (is_array($applications_existing)) {
|
|
||||||
$applications_new = array_diff($applications_list, $applications_existing);
|
|
||||||
$applications_to_delete = array_diff($applications_existing, $applications_list);
|
|
||||||
} else {
|
|
||||||
$applications_new = $applications_list;
|
|
||||||
$applications_to_delete = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$history_element_infos = (! empty($applications_new)) ? self::associateApplications($client_id, $applications_new) : false;
|
|
||||||
$history_element_infos2 = (! empty($applications_to_delete)) ? self::dissociateApplications($client_id, $applications_to_delete) : false;
|
|
||||||
|
|
||||||
$data['nb'] = self::countByClient($client_id);
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function countByClient($id)
|
|
||||||
{
|
|
||||||
return ApplicationClient::byClient($id)->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core\App;
|
|
||||||
|
|
||||||
use App\Models\Core\App\ApplicationModule;
|
|
||||||
|
|
||||||
class ApplicationModules
|
|
||||||
{
|
|
||||||
public static function select_all()
|
|
||||||
{
|
|
||||||
return ApplicationModule::all()->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core\App;
|
|
||||||
|
|
||||||
use App\Models\Core\App\ApplicationPage;
|
|
||||||
|
|
||||||
class ApplicationPages
|
|
||||||
{
|
|
||||||
public static function getBySlug($application_id, $slug)
|
|
||||||
{
|
|
||||||
$app = ApplicationPage::active()->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core\App;
|
|
||||||
|
|
||||||
use App\Models\Core\App\Application;
|
|
||||||
use App\Repositories\Languages;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
class Applications
|
|
||||||
{
|
|
||||||
public static function getFullBySlug($slug)
|
|
||||||
{
|
|
||||||
return Application::with('clients')->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ class Passwords
|
|||||||
{
|
{
|
||||||
public static function validator()
|
public static function validator()
|
||||||
{
|
{
|
||||||
$validator = new \Password\Validator(new \Password\StringHelper);
|
$validator = new \Password\Validator(new \Password\StringHelper());
|
||||||
$validator->setMinLength(5);
|
$validator->setMinLength(5);
|
||||||
$validator->setMinLowerCaseLetters(2);
|
$validator->setMinLowerCaseLetters(2);
|
||||||
$validator->setMinUpperCaseLetters(1);
|
$validator->setMinUpperCaseLetters(1);
|
||||||
|
|||||||
@@ -3,83 +3,24 @@
|
|||||||
namespace App\Repositories\Core\Auth;
|
namespace App\Repositories\Core\Auth;
|
||||||
|
|
||||||
use App\Models\Core\Auth\Permission;
|
use App\Models\Core\Auth\Permission;
|
||||||
use Yajra\DataTables\DataTables;
|
use App\Traits\Model\Basic;
|
||||||
|
|
||||||
class Permissions
|
class Permissions
|
||||||
{
|
{
|
||||||
|
use Basic;
|
||||||
|
|
||||||
public static function getModules()
|
public static function getModules()
|
||||||
{
|
{
|
||||||
return Permission::select('module')->distinct('module')->get()->pluck('module');
|
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)
|
public static function getByName($name)
|
||||||
{
|
{
|
||||||
return Permission::where('name', $name)->first();
|
return Permission::where('name', $name)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($id)
|
public static function getModel()
|
||||||
{
|
{
|
||||||
return Permission::findOrFail($id);
|
return Permission::query();
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,26 +4,21 @@ namespace App\Repositories\Core\Auth;
|
|||||||
|
|
||||||
use App\Models\Core\Auth\Role;
|
use App\Models\Core\Auth\Role;
|
||||||
use App\Models\Core\Auth\RoleUser;
|
use App\Models\Core\Auth\RoleUser;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Laratrust\Traits\LaratrustUserTrait;
|
use Laratrust\Traits\LaratrustUserTrait;
|
||||||
use Yajra\DataTables\DataTables;
|
|
||||||
|
|
||||||
class Roles
|
class Roles
|
||||||
{
|
{
|
||||||
use LaratrustUserTrait;
|
use Basic, LaratrustUserTrait;
|
||||||
|
|
||||||
public static function getListByRights()
|
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();
|
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)
|
public static function create($data)
|
||||||
{
|
{
|
||||||
$permissions = array_keys($data['permissions']);
|
$permissions = array_keys($data['permissions']);
|
||||||
@@ -35,10 +30,9 @@ class Roles
|
|||||||
return $role;
|
return $role;
|
||||||
}
|
}
|
||||||
|
|
||||||
// met à jour les informations d'une forme juridique
|
|
||||||
public static function update($input, $id = false)
|
public static function update($input, $id = false)
|
||||||
{
|
{
|
||||||
$id = ($id) ? $id : $input['id'];
|
$id = $id ? $id : $input['id'];
|
||||||
$permissions = array_keys($input['permissions']);
|
$permissions = array_keys($input['permissions']);
|
||||||
$role = self::get($id);
|
$role = self::get($id);
|
||||||
$role->update(['name' => $input['name']]);
|
$role->update(['name' => $input['name']]);
|
||||||
@@ -47,24 +41,11 @@ class Roles
|
|||||||
return $role;
|
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)
|
public static function toggle_active($id, $active)
|
||||||
{
|
{
|
||||||
return Role::find($id)->update(['active' => $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)
|
public static function getWithPermissions($id)
|
||||||
{
|
{
|
||||||
$role = self::get($id)->toArray();
|
$role = self::get($id)->toArray();
|
||||||
@@ -73,28 +54,11 @@ class Roles
|
|||||||
return $role;
|
return $role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAll()
|
|
||||||
{
|
|
||||||
return Role::orderBy('name', 'asc')->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getByName($name)
|
public static function getByName($name)
|
||||||
{
|
{
|
||||||
return Role::where('name', $name)->first();
|
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)
|
public static function getRolesByUser($user_id = false)
|
||||||
{
|
{
|
||||||
$user_id = $user_id ? $user_id : Users::getId();
|
$user_id = $user_id ? $user_id : Users::getId();
|
||||||
@@ -112,8 +76,8 @@ class Roles
|
|||||||
return self::getUsersByRole($id)->pluck('user_id');
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core\Auth;
|
|
||||||
|
|
||||||
use App\Models\Core\Auth\User;
|
|
||||||
use App\Models\Core\Auth\UserClient;
|
|
||||||
use App\Repositories\Clients;
|
|
||||||
|
|
||||||
class UserClients
|
|
||||||
{
|
|
||||||
public static function associate($user_id, $clients_list)
|
|
||||||
{
|
|
||||||
$clients_existing = self::getClientsByUser($user_id)->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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@ class Users
|
|||||||
|
|
||||||
public static function isAdmin()
|
public static function isAdmin()
|
||||||
{
|
{
|
||||||
return (self::hasRole('admin')) ? true : false;
|
return self::hasRole('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInfo($id = false)
|
public static function getInfo($id = false)
|
||||||
@@ -42,7 +42,7 @@ class Users
|
|||||||
if ($data['id'] ?? false) {
|
if ($data['id'] ?? false) {
|
||||||
unset($data['password']);
|
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'] ?? []));
|
$user->roles()->sync(array_keys($data['roles'] ?? []));
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
@@ -243,9 +243,10 @@ class Users
|
|||||||
$data = Upload::getData($file);
|
$data = Upload::getData($file);
|
||||||
$file_uploaded = Upload::store($file, $targetDir);
|
$file_uploaded = Upload::store($file, $targetDir);
|
||||||
$tab = pathinfo($file_uploaded);
|
$tab = pathinfo($file_uploaded);
|
||||||
$response['name'] = $tab['basename'];
|
|
||||||
|
|
||||||
return $response;
|
return [
|
||||||
|
'name' => $tab['basename'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update_avatar($id, $avatar)
|
public static function update_avatar($id, $avatar)
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ class Categories
|
|||||||
{
|
{
|
||||||
$categories = self::getTree(true);
|
$categories = self::getTree(true);
|
||||||
$categories = Arrays::changeKeyName($categories, 'title', 'name');
|
$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)
|
public static function getTreeVisibles($withFolder = false)
|
||||||
@@ -36,7 +35,8 @@ class Categories
|
|||||||
|
|
||||||
public static function getCategoryTreeVisibles($sale_channel_id = false)
|
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)
|
public static function getChildren($data, $withFolder = false)
|
||||||
@@ -46,7 +46,7 @@ class Categories
|
|||||||
$leaf = [];
|
$leaf = [];
|
||||||
$leaf['name'] = $item['name'];
|
$leaf['name'] = $item['name'];
|
||||||
$leaf['id'] = $item['id'];
|
$leaf['id'] = $item['id'];
|
||||||
$children = ($item['children'] ?? false) ? self::getChildren($item['children']) : false;
|
$children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
|
||||||
if ($children) {
|
if ($children) {
|
||||||
$leaf['children'] = $children;
|
$leaf['children'] = $children;
|
||||||
if ($withFolder) {
|
if ($withFolder) {
|
||||||
@@ -57,10 +57,8 @@ class Categories
|
|||||||
}
|
}
|
||||||
$tree[] = $leaf;
|
$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)
|
public static function moveTree($node_id, $target_id, $type)
|
||||||
@@ -70,22 +68,21 @@ class Categories
|
|||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'after':
|
case 'after':
|
||||||
// dump("$node_id After $target_id");
|
|
||||||
$category->afterNode($category_target);
|
$category->afterNode($category_target);
|
||||||
break;
|
break;
|
||||||
case 'inside':
|
case 'inside':
|
||||||
// dump("$node_id inside $target_id");
|
|
||||||
$category_target->appendNode($category);
|
$category_target->appendNode($category);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$category->afterNode($category_target);
|
||||||
}
|
}
|
||||||
$category->save();
|
|
||||||
|
|
||||||
return '1';
|
return $category->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create($data)
|
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 = self::getModel()->create(['name' => $data['name']]);
|
||||||
$category->appendToNode($parent)->save();
|
$category->appendToNode($parent)->save();
|
||||||
|
|
||||||
@@ -101,11 +98,6 @@ class Categories
|
|||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function destroy($id)
|
|
||||||
{
|
|
||||||
// return Category::destroy($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRoot()
|
public static function getRoot()
|
||||||
{
|
{
|
||||||
return self::getNode(1);
|
return self::getNode(1);
|
||||||
@@ -119,6 +111,5 @@ class Categories
|
|||||||
public static function getModel()
|
public static function getModel()
|
||||||
{
|
{
|
||||||
return app(Category::class);
|
return app(Category::class);
|
||||||
// return app('rinvex.categories.category');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
namespace App\Repositories\Core;
|
namespace App\Repositories\Core;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use League\Period\Period;
|
|
||||||
|
|
||||||
use function League\Period\interval_after;
|
use function League\Period\interval_after;
|
||||||
|
use League\Period\Period;
|
||||||
|
|
||||||
class DateRange
|
class DateRange
|
||||||
{
|
{
|
||||||
@@ -207,11 +206,6 @@ class DateRange
|
|||||||
$range[] = interval_after($day, $duration);
|
$range[] = interval_after($day, $duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
foreach ($period->dateRangeForward($duration) as $day) {
|
|
||||||
$daterange[] = interval_after($day, $duration);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return $range;
|
return $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,6 @@ trait DateStats
|
|||||||
|
|
||||||
public static function getModel()
|
public static function getModel()
|
||||||
{
|
{
|
||||||
return new Model;
|
return new Model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ class DateTime
|
|||||||
public static function datetoLocale($date = null)
|
public static function datetoLocale($date = null)
|
||||||
{
|
{
|
||||||
$format = self::getLocaleFormatDate();
|
$format = self::getLocaleFormatDate();
|
||||||
if (! is_null($date) && ! empty($date)) {
|
if ($date) {
|
||||||
$date = Carbon::parse($date)->format($format);
|
$date = Carbon::parse($date)->format($format);
|
||||||
} elseif ($date === 'now') {
|
} else {
|
||||||
$date = today()->format($format);
|
$date = today()->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ class DateTime
|
|||||||
public static function datetimeToLocale($date = null)
|
public static function datetimeToLocale($date = null)
|
||||||
{
|
{
|
||||||
$format = self::getLocaleFormatDatetime();
|
$format = self::getLocaleFormatDatetime();
|
||||||
if (! is_null($date) && ! empty($date)) {
|
if ($date) {
|
||||||
$date = Carbon::parse($date)->format($format);
|
$date = Carbon::parse($date)->format($format);
|
||||||
} elseif ($date === 'now') {
|
} elseif ($date === 'now') {
|
||||||
$date = now()->format($format);
|
$date = now()->format($format);
|
||||||
@@ -82,51 +82,50 @@ class DateTime
|
|||||||
$date .= ':00';
|
$date .= ':00';
|
||||||
}
|
}
|
||||||
|
|
||||||
return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
|
return $date ? Carbon::createFromFormat($format, $date) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCarbonDate($date)
|
public static function getCarbonDate($date)
|
||||||
{
|
{
|
||||||
$format = self::getLocaleFormatDate();
|
$format = self::getLocaleFormatDate();
|
||||||
|
|
||||||
return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
|
return $date ? Carbon::createFromFormat($format, $date) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convert($date)
|
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)
|
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)
|
public static function toLocale($date)
|
||||||
{
|
{
|
||||||
$format = self::getLocaleFormatDate();
|
$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)
|
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)
|
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)
|
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)
|
public static function getYearFromDate($date)
|
||||||
{
|
{
|
||||||
// return date_format(DateTime::convert($signature_date), 'Y');
|
|
||||||
$date = self::convert($date);
|
$date = self::convert($date);
|
||||||
$date = date_create($date);
|
$date = date_create($date);
|
||||||
|
|
||||||
|
|||||||
@@ -1,307 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Core;
|
|
||||||
|
|
||||||
use League\CLImate\CLImate;
|
|
||||||
use Timer;
|
|
||||||
|
|
||||||
class Debug
|
|
||||||
{
|
|
||||||
// $is_debug binaire 0 ou 1 debug, 0 ou 1 force output
|
|
||||||
public static $_instance;
|
|
||||||
|
|
||||||
public static $app;
|
|
||||||
|
|
||||||
public static $debugbar;
|
|
||||||
|
|
||||||
private function __construct()
|
|
||||||
{
|
|
||||||
// $this->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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -51,20 +51,13 @@ class Export
|
|||||||
$styleFont->setBold(true);
|
$styleFont->setBold(true);
|
||||||
$styleFont->setSize(12);
|
$styleFont->setSize(12);
|
||||||
$styleFont->setName('Arial');
|
$styleFont->setName('Arial');
|
||||||
// $styleFont->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
|
|
||||||
$this->sheet->setCellValue($coord, $txt);
|
$this->sheet->setCellValue($coord, $txt);
|
||||||
if ($this->debug) {
|
|
||||||
echo "Col $col Ligne $lig : $coord Text $txt<br/>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeCell($lig, $col, $txt)
|
public function writeCell($lig, $col, $txt)
|
||||||
{
|
{
|
||||||
$coord = $this->conv($lig, $col);
|
$coord = $this->conv($lig, $col);
|
||||||
$this->sheet->setCellValue($coord, $txt);
|
$this->sheet->setCellValue($coord, $txt);
|
||||||
if ($this->debug) {
|
|
||||||
echo "Col $col Ligne $lig : $coord Text $txt<br/>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportRow($data, $config = null)
|
public function exportRow($data, $config = null)
|
||||||
@@ -129,26 +122,20 @@ class Export
|
|||||||
if ($this->debug) {
|
if ($this->debug) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Debug::message($this->xls);
|
|
||||||
$objWriter = PHPExcel_IOFactory::createWriter($this->xls, 'Excel2007');
|
$objWriter = PHPExcel_IOFactory::createWriter($this->xls, 'Excel2007');
|
||||||
// Debug::message($objWriter);
|
|
||||||
// exit;
|
|
||||||
if (! $this->stockage) {
|
if (! $this->stockage) {
|
||||||
$this->header();
|
$this->header();
|
||||||
$objWriter->save('php://output');
|
$objWriter->save('php://output');
|
||||||
} else {
|
} else {
|
||||||
// $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
|
||||||
$objWriter->save('text.xlsx');
|
$objWriter->save('text.xlsx');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function conv($lig, $col)
|
public function conv($lig, $col)
|
||||||
{
|
{
|
||||||
$c = static::convColtoTxt($col);
|
$c = static::convColtoTxt($col);
|
||||||
$lig = $this->lig;
|
|
||||||
|
|
||||||
return "$c$lig";
|
return $c.$lig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convColtoTxt($col)
|
public function convColtoTxt($col)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ class Geolocation
|
|||||||
{
|
{
|
||||||
public static function getCoords($address, $zipcode, $city)
|
public static function getCoords($address, $zipcode, $city)
|
||||||
{
|
{
|
||||||
if (! (! empty($address) && ! empty($zipcode) && ! empty($city))) {
|
if (! ($address && $zipcode && $city)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$address = $address.' , '.$city.' '.$zipcode.' , '.'France';
|
$address .= ' , '.$city.' '.$zipcode.' , France';
|
||||||
|
|
||||||
$geocode = app('geocoder')->geocode($address)->get();
|
$geocode = app('geocoder')->geocode($address)->get();
|
||||||
|
|
||||||
@@ -17,15 +17,10 @@ class Geolocation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$res = $geocode[0]->getCoordinates()->toArray();
|
$res = $geocode[0]->getCoordinates()->toArray();
|
||||||
// dump($res);
|
|
||||||
$longitude = $res[0];
|
$longitude = $res[0];
|
||||||
$latitude = $res[1];
|
$latitude = $res[1];
|
||||||
|
|
||||||
// dump($latitude);
|
|
||||||
// dump($longitude);
|
|
||||||
// exit;
|
|
||||||
return ['latitude' => $latitude, 'longitude' => $longitude];
|
return ['latitude' => $latitude, 'longitude' => $longitude];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function autocomplete($query)
|
public static function autocomplete($query)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class HelperDate
|
|||||||
{
|
{
|
||||||
public static function toLocaleFormat($date)
|
public static function toLocaleFormat($date)
|
||||||
{
|
{
|
||||||
if (! (! is_null($date) && ! empty($date))) {
|
if (! $date) {
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
$locale = session('locale');
|
$locale = session('locale');
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ class MailTemplates
|
|||||||
$m = new Mustache_Engine();
|
$m = new Mustache_Engine();
|
||||||
|
|
||||||
return $m->render($html_template, $data);
|
return $m->render($html_template, $data);
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getModel()
|
public static function getModel()
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ class Medias
|
|||||||
|
|
||||||
public static function getConversion($image, $conversion = '')
|
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;
|
return $conversion ? '/conversions/'.$image->name.'-'.$conversion.'.jpg' : $image->file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ class Medias
|
|||||||
$id = $image['id'];
|
$id = $image['id'];
|
||||||
$filename = self::getFilename($image);
|
$filename = self::getFilename($image);
|
||||||
|
|
||||||
return "/storage/$id/$filename";
|
return "/storage/{$id}/{$filename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getThumbSrc($image)
|
public static function getThumbSrc($image)
|
||||||
|
|||||||
@@ -2,31 +2,18 @@
|
|||||||
|
|
||||||
namespace App\Repositories\Core\Menu;
|
namespace App\Repositories\Core\Menu;
|
||||||
|
|
||||||
use Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Lavary\Menu\Builder as LavaryMenuBuilder;
|
use Lavary\Menu\Builder as LavaryMenuBuilder;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Builder.
|
|
||||||
*
|
|
||||||
* @property Collection $items;
|
|
||||||
*/
|
|
||||||
class Builder extends LavaryMenuBuilder
|
class Builder extends LavaryMenuBuilder
|
||||||
{
|
{
|
||||||
private $root = [];
|
private $root = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an item to the menu.
|
|
||||||
*
|
|
||||||
* @param string $title
|
|
||||||
* @param string $options
|
|
||||||
* @return \Lavary\Menu\Item|Item
|
|
||||||
*/
|
|
||||||
public function add($title, $options = '')
|
public function add($title, $options = '')
|
||||||
{
|
{
|
||||||
$title = sprintf('<span>%s</span>', $title);
|
$title = sprintf('<span>%s</span>', $title);
|
||||||
|
|
||||||
$id = isset($options['id']) ? $options['id'] : $this->id();
|
$id = $options['id'] ?? $this->id();
|
||||||
|
|
||||||
$item = new Item($this, $id, $title, $options);
|
$item = new Item($this, $id, $title, $options);
|
||||||
|
|
||||||
@@ -37,7 +24,7 @@ class Builder extends LavaryMenuBuilder
|
|||||||
if (isset($options['role']) || isset($options['permission'])) {
|
if (isset($options['role']) || isset($options['permission'])) {
|
||||||
$ability = ['admin'];
|
$ability = ['admin'];
|
||||||
if (isset($options['role'])) {
|
if (isset($options['role'])) {
|
||||||
$ability = $ability + explode(',', $options['role']);
|
$ability += explode(',', $options['role']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$permission = null;
|
$permission = null;
|
||||||
@@ -57,14 +44,6 @@ class Builder extends LavaryMenuBuilder
|
|||||||
return $item;
|
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 = '')
|
public function addTo($id, $title, $options = '')
|
||||||
{
|
{
|
||||||
$parent = $this->whereId($id)->first();
|
$parent = $this->whereId($id)->first();
|
||||||
@@ -72,8 +51,6 @@ class Builder extends LavaryMenuBuilder
|
|||||||
if (isset($parent)) {
|
if (isset($parent)) {
|
||||||
if (! isset($this->root[$parent->id])) {
|
if (! isset($this->root[$parent->id])) {
|
||||||
$parent->attr(['url' => '#', 'class' => 'treeview']);
|
$parent->attr(['url' => '#', 'class' => 'treeview']);
|
||||||
// $str = '<span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>';
|
|
||||||
// $parent->append($str);
|
|
||||||
$this->root[$parent->id] = true;
|
$this->root[$parent->id] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ use Lavary\Menu\Item as LavaryMenuItem;
|
|||||||
|
|
||||||
class Item extends LavaryMenuItem
|
class Item extends LavaryMenuItem
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Set the item icon using font-awesome.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function icon($icon)
|
public function icon($icon)
|
||||||
{
|
{
|
||||||
$this->prepend(sprintf('<i class="%s"></i>', $icon));
|
$this->prepend(sprintf('<i class="%s"></i>', $icon));
|
||||||
@@ -19,12 +13,6 @@ class Item extends LavaryMenuItem
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the item order.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function order($order)
|
public function order($order)
|
||||||
{
|
{
|
||||||
$this->data('order', $order);
|
$this->data('order', $order);
|
||||||
@@ -32,15 +20,9 @@ class Item extends LavaryMenuItem
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Make the item active.
|
|
||||||
*
|
|
||||||
* @param string|array $routes
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function activeIfRoute($routes = null)
|
public function activeIfRoute($routes = null)
|
||||||
{
|
{
|
||||||
if (! empty($routes)) {
|
if ($routes) {
|
||||||
if (is_string($routes)) {
|
if (is_string($routes)) {
|
||||||
$routes = [$routes];
|
$routes = [$routes];
|
||||||
}
|
}
|
||||||
@@ -56,7 +38,6 @@ class Item extends LavaryMenuItem
|
|||||||
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
|
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump($this);
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace Sebastienheyd\Boilerplate\Menu;
|
namespace Sebastienheyd\Boilerplate\Menu;
|
||||||
|
|
||||||
use Sebastienheyd\Boilerplate\Menu\Builder as Builder;
|
|
||||||
|
|
||||||
class Logs
|
class Logs
|
||||||
{
|
{
|
||||||
public function make(Builder $menu)
|
public function make(Builder $menu)
|
||||||
@@ -12,20 +10,18 @@ class Logs
|
|||||||
->id('logs')
|
->id('logs')
|
||||||
->order(1100);
|
->order(1100);
|
||||||
|
|
||||||
$menu->addTo(
|
$menu->addTo('logs', __('boilerplate::logs.menu.stats'), [
|
||||||
'logs', __('boilerplate::logs.menu.stats'), [
|
|
||||||
'route' => 'boilerplate.logs.dashboard',
|
'route' => 'boilerplate.logs.dashboard',
|
||||||
'permission' => 'logs', ]
|
'permission' => 'logs',
|
||||||
)
|
])->order(1110)->activeIfRoute('boilerplate.logs.dashboard');
|
||||||
->order(1110)
|
|
||||||
->activeIfRoute('boilerplate.logs.dashboard');
|
|
||||||
|
|
||||||
$menu->addTo(
|
$menu->addTo('logs', __('boilerplate::logs.menu.reports'), [
|
||||||
'logs', __('boilerplate::logs.menu.reports'), [
|
|
||||||
'route' => 'boilerplate.logs.list',
|
'route' => 'boilerplate.logs.list',
|
||||||
'permission' => 'logs', ]
|
'permission' => 'logs',
|
||||||
)
|
])->order(1120)->activeIfRoute([
|
||||||
->order(1120)
|
'boilerplate.logs.list',
|
||||||
->activeIfRoute(['boilerplate.logs.list', 'boilerplate.logs.show', 'boilerplate.logs.filter']);
|
'boilerplate.logs.show',
|
||||||
|
'boilerplate.logs.filter',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Repositories\Core\Menu;
|
namespace App\Repositories\Core\Menu;
|
||||||
|
|
||||||
use App\Repositories\Core\Menu\Builder as Builder;
|
|
||||||
|
|
||||||
class Users
|
class Users
|
||||||
{
|
{
|
||||||
public function make(Builder $menu)
|
public function make(Builder $menu)
|
||||||
@@ -12,26 +10,20 @@ class Users
|
|||||||
->id('access')
|
->id('access')
|
||||||
->order(1000);
|
->order(1000);
|
||||||
|
|
||||||
$menu->addTo(
|
$menu->addTo('access', __('boilerplate::users.list.title'), [
|
||||||
'access', __('boilerplate::users.list.title'), [
|
|
||||||
'route' => 'boilerplate.users.index',
|
'route' => 'boilerplate.users.index',
|
||||||
'permission' => 'users_crud', ]
|
'permission' => 'users_crud',
|
||||||
)
|
])->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
|
||||||
->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
|
|
||||||
|
|
||||||
$menu->addTo(
|
$menu->addTo('access', __('boilerplate::users.create.title'), [
|
||||||
'access', __('boilerplate::users.create.title'), [
|
|
||||||
'route' => 'boilerplate.users.create',
|
'route' => 'boilerplate.users.create',
|
||||||
'permission' => 'users_crud', ]
|
'permission' => 'users_crud',
|
||||||
)
|
])->activeIfRoute('boilerplate.users.create');
|
||||||
->activeIfRoute('boilerplate.users.create');
|
|
||||||
|
|
||||||
$menu->addTo(
|
$menu->addTo('access', __('boilerplate::layout.role_management'), [
|
||||||
'access', __('boilerplate::layout.role_management'), [
|
|
||||||
'route' => 'boilerplate.roles.index',
|
'route' => 'boilerplate.roles.index',
|
||||||
'permission' => 'roles_crud', ]
|
'permission' => 'roles_crud',
|
||||||
)
|
])->activeIfRoute('boilerplate.roles.*');
|
||||||
->activeIfRoute('boilerplate.roles.*');
|
|
||||||
|
|
||||||
$menu->addTo('access', __('boilerplate::users.profile.title'), ['route' => 'boilerplate.user.profile'])
|
$menu->addTo('access', __('boilerplate::users.profile.title'), ['route' => 'boilerplate.user.profile'])
|
||||||
->activeIfRoute('boilerplate.user.profile');
|
->activeIfRoute('boilerplate.user.profile');
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ class Number
|
|||||||
{
|
{
|
||||||
public static function price($value)
|
public static function price($value)
|
||||||
{
|
{
|
||||||
$formatter = new Numeral;
|
$formatter = new Numeral();
|
||||||
$languageManager = new LanguageManager;
|
$languageManager = new LanguageManager();
|
||||||
$languageManager->setCulture('fr-FR');
|
$languageManager->setCulture('fr-FR');
|
||||||
|
|
||||||
$formatter->setLanguageManager($languageManager);
|
$formatter->setLanguageManager($languageManager);
|
||||||
|
|
||||||
$price = $formatter->format($value, '0,0');
|
return $formatter->format($value, '0,0');
|
||||||
|
|
||||||
return $price;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Stat
|
|||||||
|
|
||||||
public static function getStatsbyMultiVar($var, $var_option = '')
|
public static function getStatsbyMultiVar($var, $var_option = '')
|
||||||
{
|
{
|
||||||
if (empty($var_option)) {
|
if ($var_option) {
|
||||||
$var_option = $var;
|
$var_option = $var;
|
||||||
}
|
}
|
||||||
$options = self::getOption($var_option);
|
$options = self::getOption($var_option);
|
||||||
@@ -52,39 +52,34 @@ class Stat
|
|||||||
|
|
||||||
public static function getCountByPeriod($var, $begin, $end)
|
public static function getCountByPeriod($var, $begin, $end)
|
||||||
{
|
{
|
||||||
$count = self::getModel()
|
return self::getModel()
|
||||||
->whereBetween($var, $begin, $end)
|
->whereBetween($var, $begin, $end)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCountbyVar($var)
|
public static function getCountbyVar($var)
|
||||||
{
|
{
|
||||||
$db = self::getInstance()->app->db;
|
$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)
|
->groupBy($var)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
// var_Debug::message($data);
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getStatsbyOptions($var, $var_option = '')
|
public static function getStatsbyOptions($var, $var_option = '')
|
||||||
{
|
{
|
||||||
if (empty($var_option)) {
|
if ($var_option ?? false) {
|
||||||
$var_option = $var;
|
$var_option = $var;
|
||||||
}
|
}
|
||||||
$options = self::getInstance()->controller->getOption($var_option);
|
$options = self::getInstance()->controller->getOption($var_option);
|
||||||
$nb = self::getCountbyOption($var);
|
$nb = self::getCountbyOption($var);
|
||||||
// var_Debug::message($nb);
|
$data = [];
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
$y = (int) $nb[$key];
|
$y = (int) $nb[$key];
|
||||||
$data[] = ['y' => $y, 'name' => $value];
|
$data[] = ['y' => $y, 'name' => $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_Debug::message($data);
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +103,7 @@ class Stat
|
|||||||
|
|
||||||
public static function getStatsbyMultiOptions($var, $options)
|
public static function getStatsbyMultiOptions($var, $options)
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
$nb = self::getCountbyBin($var, $key);
|
$nb = self::getCountbyBin($var, $key);
|
||||||
$data[] = ['y' => $nb, 'name' => $value];
|
$data[] = ['y' => $nb, 'name' => $value];
|
||||||
@@ -119,11 +115,8 @@ class Stat
|
|||||||
public static function getCountbyBin($var, $value)
|
public static function getCountbyBin($var, $value)
|
||||||
{
|
{
|
||||||
$bit = pow(2, $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')
|
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Trees
|
|||||||
$leaf = [];
|
$leaf = [];
|
||||||
$leaf['name'] = $item['name'];
|
$leaf['name'] = $item['name'];
|
||||||
$leaf['id'] = $item['id'];
|
$leaf['id'] = $item['id'];
|
||||||
$children = (isset($item['children'])) ? self::getChildren($item['children']) : false;
|
$children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
|
||||||
if ($children) {
|
if ($children) {
|
||||||
$leaf['children'] = $children;
|
$leaf['children'] = $children;
|
||||||
}
|
}
|
||||||
@@ -35,22 +35,21 @@ class Trees
|
|||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'after':
|
case 'after':
|
||||||
// dump("$node_id After $target_id");
|
|
||||||
$item->afterNode($item_target);
|
$item->afterNode($item_target);
|
||||||
break;
|
break;
|
||||||
case 'inside':
|
case 'inside':
|
||||||
// dump("$node_id inside $target_id");
|
|
||||||
$item_target->appendNode($item);
|
$item_target->appendNode($item);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$item->afterNode($item_target);
|
||||||
}
|
}
|
||||||
$item->save();
|
|
||||||
|
|
||||||
return '1';
|
return $item->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create($data, $model)
|
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 = $model->create(['name' => $data['name']]);
|
||||||
$tree->appendToNode($parent)->save();
|
$tree->appendToNode($parent)->save();
|
||||||
|
|
||||||
|
|||||||
@@ -3,38 +3,31 @@
|
|||||||
namespace App\Repositories\Core;
|
namespace App\Repositories\Core;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Intervention\Image\Facades\Image as Image;
|
use Intervention\Image\Facades\Image;
|
||||||
|
|
||||||
class Upload
|
class Upload
|
||||||
{
|
{
|
||||||
public static function getData($file)
|
public static function getData($file)
|
||||||
{
|
{
|
||||||
$data['filename'] = $file->getClientOriginalName();
|
return [
|
||||||
$data['filetype'] = $file->getClientOriginalExtension();
|
'filename' => $file->getClientOriginalName(),
|
||||||
$data['filesize'] = $file->getSize();
|
'filetype' => $file->getClientOriginalExtension(),
|
||||||
$data['mime'] = $file->getMimeType();
|
'filesize' => $file->getSize(),
|
||||||
|
'mime' => $file->getMimeType(),
|
||||||
return $data;
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUuid($file, $data)
|
public static function getUuid($file, $data)
|
||||||
{
|
{
|
||||||
$data = (is_array($data)) ? (object) $data : $data;
|
$data = is_array($data) ? (object) $data : $data;
|
||||||
$pos = strrpos($file, '/');
|
$pos = strrpos($file, '/');
|
||||||
$uuid = substr($file, $pos + 1);
|
$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)
|
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();
|
$request = Request();
|
||||||
|
|
||||||
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
|
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
|
||||||
@@ -43,14 +36,11 @@ class Upload
|
|||||||
public static function store($file, $path)
|
public static function store($file, $path)
|
||||||
{
|
{
|
||||||
return Storage::putFile($path, $file);
|
return Storage::putFile($path, $file);
|
||||||
// return $file->store($filepath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storePublic($file, $filepath)
|
public static function storePublic($file, $filepath)
|
||||||
{
|
{
|
||||||
return Storage::putFile($filepath, $file, 'public');
|
return Storage::putFile($filepath, $file, 'public');
|
||||||
// $filepath = 'public/' . $filepath;
|
|
||||||
// return $file->store($filepath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createThumb($file, $size, $sub = false)
|
public static function createThumb($file, $size, $sub = false)
|
||||||
@@ -61,12 +51,6 @@ class Upload
|
|||||||
return Image::make($filename)->orientate()->widen($size)->save($thumb);
|
return Image::make($filename)->orientate()->widen($size)->save($thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static function getPath($file) {
|
|
||||||
return 'public/' . self::getFilename($file);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static function getPublicPath($file)
|
public static function getPublicPath($file)
|
||||||
{
|
{
|
||||||
return storage_path('app/public/'.self::getFilename($file));
|
return storage_path('app/public/'.self::getFilename($file));
|
||||||
@@ -94,7 +78,7 @@ class Upload
|
|||||||
|
|
||||||
public static function getFilename($file)
|
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);
|
return $file->filepath.'/'.self::getName($file);
|
||||||
}
|
}
|
||||||
@@ -102,24 +86,18 @@ class Upload
|
|||||||
public static function getThumbFilename($file, $sub = false)
|
public static function getThumbFilename($file, $sub = false)
|
||||||
{
|
{
|
||||||
$sub = $sub ? $sub : 'thumbs/';
|
$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);
|
return $file->filepath.'/'.$sub.self::getName($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function 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);
|
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)
|
public static function fix($path)
|
||||||
{
|
{
|
||||||
if (! self::isWindows()) {
|
if (! self::isWindows()) {
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class Basket
|
|||||||
public static function remove($key, $value)
|
public static function remove($key, $value)
|
||||||
{
|
{
|
||||||
$data = self::get($key);
|
$data = self::get($key);
|
||||||
if (($index = array_search($value, $data)) !== false) {
|
$index = array_search($value, $data);
|
||||||
|
if ($index !== false) {
|
||||||
unset($data[$index]);
|
unset($data[$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,67 +5,45 @@ namespace App\Repositories\Core\User\Notifications;
|
|||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class NewUser extends Notification
|
class NewUser extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notification's delivery channels.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
return ['mail'];
|
return ['mail'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the mail representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
||||||
*/
|
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
$currentUser = \Auth::user();
|
$currentUser = Auth::user();
|
||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->markdown('notifications.email')
|
->markdown('notifications.email')
|
||||||
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
|
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
|
||||||
->subject(__('notifications.newuser.subject', ['name' => config('app.name')]))
|
->subject(__('notifications.newuser.subject', ['name' => config('app.name')]))
|
||||||
->line(
|
->line(
|
||||||
__(
|
__('notifications.newuser.intro', [
|
||||||
'notifications.newuser.intro', [
|
|
||||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||||
]
|
])
|
||||||
)
|
|
||||||
)
|
)
|
||||||
->action(
|
->action(
|
||||||
__('notifications.newuser.button'),
|
__('notifications.newuser.button'),
|
||||||
route('users.firstlogin', $notifiable->remember_token)
|
route('users.firstlogin', $notifiable->remember_token)
|
||||||
)
|
)
|
||||||
->salutation(
|
->salutation(
|
||||||
__(
|
__('notifications.salutation', [
|
||||||
'notifications.salutation', [
|
|
||||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||||
]
|
])
|
||||||
)
|
|
||||||
)
|
)
|
||||||
->line(__('notifications.newuser.outro'));
|
->line(__('notifications.newuser.outro'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the array representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,6 @@ use Illuminate\Notifications\Messages\MailMessage;
|
|||||||
|
|
||||||
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
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)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
@@ -26,5 +19,4 @@ class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
|||||||
)
|
)
|
||||||
->line(__('notifications.resetpassword.outro'));
|
->line(__('notifications.resetpassword.outro'));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ class ShopCartStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put($key, $value)
|
public function put($key, $value)
|
||||||
{
|
{
|
||||||
if ($row = CartStorage::find($key)) {
|
$row = CartStorage::find($key);
|
||||||
|
if ($row) {
|
||||||
$row->cart_data = $value;
|
$row->cart_data = $value;
|
||||||
$row->save();
|
$row->save();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getSiblingsDescriptions($id)
|
public static function getSiblingsDescriptions($id)
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
$siblings = self::getSiblings($id);
|
$siblings = self::getSiblings($id);
|
||||||
foreach ($siblings as $sibling) {
|
foreach ($siblings as $sibling) {
|
||||||
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
||||||
@@ -76,6 +77,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getOptionsWithNature()
|
public static function getOptionsWithNature()
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
$articles = Article::with(['article_nature'])->get();
|
$articles = Article::with(['article_nature'])->get();
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$data[$article->id] = ($article->article_nature->name ?? null).' - '.$article->name;
|
$data[$article->id] = ($article->article_nature->name ?? null).' - '.$article->name;
|
||||||
@@ -117,6 +119,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getFullDescriptionByArticle($article)
|
public static function getFullDescriptionByArticle($article)
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
switch ($article->product_type) {
|
switch ($article->product_type) {
|
||||||
case 'App\Models\Botanic\Variety':
|
case 'App\Models\Botanic\Variety':
|
||||||
$data['variety'] = $article->product->description;
|
$data['variety'] = $article->product->description;
|
||||||
@@ -141,13 +144,6 @@ class Articles
|
|||||||
if ($siblings) {
|
if ($siblings) {
|
||||||
array_push($data, $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;
|
$data['description'] = $article->description;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -155,6 +151,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getArticlesByHomepage()
|
public static function getArticlesByHomepage()
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
$shelves = Categories::getByHomepage();
|
$shelves = Categories::getByHomepage();
|
||||||
foreach ($shelves as $shelve) {
|
foreach ($shelves as $shelve) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
@@ -285,7 +282,7 @@ class Articles
|
|||||||
$article_nature_ids = $options['article_nature_ids'] ?? false;
|
$article_nature_ids = $options['article_nature_ids'] ?? false;
|
||||||
$product_type = $options['product_type'] ?? 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 = $category_id ? $model->byCategoryParent($category_id) : $model;
|
||||||
$model = $tags ? $model->byTags($tags) : $model;
|
$model = $tags ? $model->byTags($tags) : $model;
|
||||||
$model = $search ? $model->search($search) : $model;
|
$model = $search ? $model->search($search) : $model;
|
||||||
@@ -307,7 +304,9 @@ class Articles
|
|||||||
|
|
||||||
public static function getFull($id)
|
public static function getFull($id)
|
||||||
{
|
{
|
||||||
$data['article'] = self::getArticleEdit($id);
|
$data = [
|
||||||
|
'article' => self::getArticleEdit($id),
|
||||||
|
];
|
||||||
|
|
||||||
return self::getMeta($data);
|
return self::getMeta($data);
|
||||||
}
|
}
|
||||||
@@ -333,6 +332,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getInheritedByProduct($product_id, $product_type)
|
public static function getInheritedByProduct($product_id, $product_type)
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
switch ($product_type) {
|
switch ($product_type) {
|
||||||
case 'App\Models\Botanic\Variety':
|
case 'App\Models\Botanic\Variety':
|
||||||
$product = Varieties::get($product_id);
|
$product = Varieties::get($product_id);
|
||||||
@@ -414,7 +414,6 @@ class Articles
|
|||||||
|
|
||||||
$data['categories_options'] = Categories::getOptions();
|
$data['categories_options'] = Categories::getOptions();
|
||||||
$data['natures_options'] = ArticleNatures::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['tags_list'] = TagGroups::getTreeTags();
|
||||||
$data['models_options'] = [
|
$data['models_options'] = [
|
||||||
'App\Models\Botanic\Specie' => 'Espèces',
|
'App\Models\Botanic\Specie' => 'Espèces',
|
||||||
@@ -439,7 +438,7 @@ class Articles
|
|||||||
{
|
{
|
||||||
$models = self::getProductTypesModelsByCategory($category_id);
|
$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)
|
public static function getProductTypesModelsByCategory($category_id)
|
||||||
@@ -549,6 +548,7 @@ class Articles
|
|||||||
$merchandise = $article->product ?? false;
|
$merchandise = $article->product ?? false;
|
||||||
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
|
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
return $images;
|
return $images;
|
||||||
@@ -575,6 +575,7 @@ class Articles
|
|||||||
case 'App\Models\Shop\Merchandise':
|
case 'App\Models\Shop\Merchandise':
|
||||||
$image = $article->product->image ?? false;
|
$image = $article->product->image ?? false;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
@@ -591,9 +592,6 @@ class Articles
|
|||||||
$tags = $data['tags'] ?? false;
|
$tags = $data['tags'] ?? false;
|
||||||
unset($data['tags']);
|
unset($data['tags']);
|
||||||
|
|
||||||
$prices = $data['prices'] ?? false;
|
|
||||||
unset($data['prices']);
|
|
||||||
|
|
||||||
$article = self::store($data);
|
$article = self::store($data);
|
||||||
self::storeImages($article, $images);
|
self::storeImages($article, $images);
|
||||||
self::storeCategories($article, $categories);
|
self::storeCategories($article, $categories);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Baskets
|
|||||||
public static function addBasket($offerId, $quantity = 1, $update = false)
|
public static function addBasket($offerId, $quantity = 1, $update = false)
|
||||||
{
|
{
|
||||||
if (ShopCart::has($offerId) && ! $quantity) {
|
if (ShopCart::has($offerId) && ! $quantity) {
|
||||||
$ret = ShopCart::remove($offerId);
|
ShopCart::remove($offerId);
|
||||||
}
|
}
|
||||||
$data = $quantity ? self::getBasketData($offerId, $quantity) : false;
|
$data = $quantity ? self::getBasketData($offerId, $quantity) : false;
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ class Baskets
|
|||||||
$total = 0;
|
$total = 0;
|
||||||
$totalTaxed = 0;
|
$totalTaxed = 0;
|
||||||
$totalWeight = 0;
|
$totalWeight = 0;
|
||||||
|
$detail = [];
|
||||||
$basket = ShopCart::getContent();
|
$basket = ShopCart::getContent();
|
||||||
$offers = Offers::getWithVariationByIds(self::getIds());
|
$offers = Offers::getWithVariationByIds(self::getIds());
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ class Baskets
|
|||||||
}
|
}
|
||||||
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
|
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
|
||||||
|
|
||||||
$data = [
|
return [
|
||||||
'detail' => $detail,
|
'detail' => $detail,
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
'taxes' => $totalTaxed - $total,
|
'taxes' => $totalTaxed - $total,
|
||||||
@@ -54,8 +55,6 @@ class Baskets
|
|||||||
'weight' => $totalWeight,
|
'weight' => $totalWeight,
|
||||||
'sale_channel' => SaleChannels::getArray($saleChannelId),
|
'sale_channel' => SaleChannels::getArray($saleChannelId),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data ?? false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRowDetail($item, $offer, $prices, $weight)
|
public static function getRowDetail($item, $offer, $prices, $weight)
|
||||||
@@ -132,7 +131,6 @@ class Baskets
|
|||||||
public static function getArticleName(&$offer)
|
public static function getArticleName(&$offer)
|
||||||
{
|
{
|
||||||
return $offer->article->name;
|
return $offer->article->name;
|
||||||
// return $offer->article->name . ' (' . $offer->variation->name . ')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getIds()
|
public static function getIds()
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ namespace App\Repositories\Shop;
|
|||||||
use App\Models\Shop\Category;
|
use App\Models\Shop\Category;
|
||||||
use App\Repositories\Core\Categories as CategoryTrees;
|
use App\Repositories\Core\Categories as CategoryTrees;
|
||||||
use App\Repositories\Core\Tag;
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
|
||||||
class Categories
|
class Categories
|
||||||
{
|
{
|
||||||
|
use Basic;
|
||||||
|
|
||||||
public static function getAncestorsByArticle($id)
|
public static function getAncestorsByArticle($id)
|
||||||
{
|
{
|
||||||
$category = Articles::get($id)->categories()->first();
|
$category = Articles::get($id)->categories()->first();
|
||||||
@@ -31,16 +34,6 @@ class Categories
|
|||||||
return Category::hasAvailableOffers()->visible()->homepage()->orderBy('name', 'asc')->get();
|
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)
|
public static function getFull($id)
|
||||||
{
|
{
|
||||||
$category = self::get($id, ['Parent']);
|
$category = self::get($id, ['Parent']);
|
||||||
@@ -72,11 +65,6 @@ class Categories
|
|||||||
return CategoryTrees::getTree();
|
return CategoryTrees::getTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOptions()
|
|
||||||
{
|
|
||||||
return Category::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
{
|
{
|
||||||
$images = $data['images'] ?? false;
|
$images = $data['images'] ?? false;
|
||||||
@@ -92,13 +80,6 @@ class Categories
|
|||||||
return $category;
|
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)
|
public static function storeTags($category, $tags)
|
||||||
{
|
{
|
||||||
return Tag::storeTags($category, $tags);
|
return Tag::storeTags($category, $tags);
|
||||||
@@ -146,26 +127,7 @@ class Categories
|
|||||||
return CategoryTrees::moveTree($node_id, $target_id, $type);
|
return CategoryTrees::moveTree($node_id, $target_id, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create($data)
|
public static function toggleVisible($id, $visible)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
return self::update(['visible' => $visible], $id);
|
return self::update(['visible' => $visible], $id);
|
||||||
}
|
}
|
||||||
@@ -179,4 +141,9 @@ class Categories
|
|||||||
{
|
{
|
||||||
return app('rinvex.categories.category')->find(1);
|
return app('rinvex.categories.category')->find(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getModel()
|
||||||
|
{
|
||||||
|
return Category::query();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class CustomerAddresses
|
|||||||
'zipcode' => $data['delivery_zipcode'],
|
'zipcode' => $data['delivery_zipcode'],
|
||||||
'city' => $data['delivery_city'],
|
'city' => $data['delivery_city'],
|
||||||
]);
|
]);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return self::store([
|
return self::store([
|
||||||
'customer_id' => $userId,
|
'customer_id' => $userId,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
@@ -31,7 +32,6 @@ class CustomerAddresses
|
|||||||
'city' => $data['city'],
|
'city' => $data['city'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static function toggleActive($id, $active)
|
public static function toggleActive($id, $active)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class Customers
|
|||||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||||
'orders' => $datatableOrders->html(),
|
'orders' => $datatableOrders->html(),
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAvatar($id = false)
|
public static function getAvatar($id = false)
|
||||||
@@ -160,14 +159,10 @@ class Customers
|
|||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
{
|
{
|
||||||
// $invoices = $data['invoices'];
|
|
||||||
$saleChannels = $data['sale_channels'];
|
$saleChannels = $data['sale_channels'];
|
||||||
// unset($data['invoices']);
|
|
||||||
unset($data['sale_channels']);
|
unset($data['sale_channels']);
|
||||||
$customer = self::store($data);
|
$customer = self::store($data);
|
||||||
if ($customer) {
|
if ($customer) {
|
||||||
// self::storeAddresses($customer->id, $deliveries);
|
|
||||||
// self::storeAddresses($customer->id, $invoices);
|
|
||||||
self::storeSaleChannels($customer->id, $saleChannels);
|
self::storeSaleChannels($customer->id, $saleChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,11 +174,9 @@ class Customers
|
|||||||
if (! $deliveries) {
|
if (! $deliveries) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$deliveries = collect($deliveries)->transform(
|
$deliveries = collect($deliveries)->transform(function ($item) {
|
||||||
function ($item) {
|
|
||||||
return (int) $item;
|
return (int) $item;
|
||||||
}
|
})->toArray();
|
||||||
)->toArray();
|
|
||||||
|
|
||||||
return $customer->deliveries()->sync($deliveries);
|
return $customer->deliveries()->sync($deliveries);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,8 @@ class Offers
|
|||||||
$tags = Categories::getTagsByCategory($category);
|
$tags = Categories::getTagsByCategory($category);
|
||||||
$offers1 = self::getByCategory($category_id)->toArray();
|
$offers1 = self::getByCategory($category_id)->toArray();
|
||||||
$offers2 = self::getByTags($tags)->toArray();
|
$offers2 = self::getByTags($tags)->toArray();
|
||||||
$data = array_merge($offers1, $offers2);
|
|
||||||
|
|
||||||
return $data;
|
return array_merge($offers1, $offers2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getByCategory($category_id)
|
public static function getByCategory($category_id)
|
||||||
|
|||||||
@@ -3,59 +3,25 @@
|
|||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use App\Models\Shop\Price;
|
use App\Models\Shop\Price;
|
||||||
use Yajra\DataTables\DataTables;
|
use App\Traits\Model\Basic;
|
||||||
|
|
||||||
class Prices
|
class Prices
|
||||||
{
|
{
|
||||||
|
use Basic;
|
||||||
|
|
||||||
public static function getByArticle($id)
|
public static function getByArticle($id)
|
||||||
{
|
{
|
||||||
$data['prices'] = Price::byArticle($id)->notGeneric()->get()->toArray();
|
return [
|
||||||
$data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices', 'generic.category'])->get()->toArray();
|
'prices' => Price::byArticle($id)->notGeneric()->get()->toArray(),
|
||||||
|
'generics' => Price::byArticle($id)->generic()->with([
|
||||||
return $data;
|
'generic.prices',
|
||||||
|
'generic.category',
|
||||||
|
])->get()->toArray(),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDatatable()
|
public static function getModel()
|
||||||
{
|
{
|
||||||
$model = Price::orderBy('name');
|
return Price::query();
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ namespace App\Repositories\Shop;
|
|||||||
|
|
||||||
use App\Models\Shop\Tag;
|
use App\Models\Shop\Tag;
|
||||||
use App\Models\Shop\TagGroup;
|
use App\Models\Shop\TagGroup;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class TagGroups
|
class TagGroups
|
||||||
{
|
{
|
||||||
public static function getOptions()
|
use Basic;
|
||||||
{
|
|
||||||
return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getWithTagsAndCountOffers($category_id = false)
|
public static function getWithTagsAndCountOffers($category_id = false)
|
||||||
{
|
{
|
||||||
@@ -62,11 +60,6 @@ class TagGroups
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAll()
|
|
||||||
{
|
|
||||||
return TagGroup::orderBy('name', 'asc')->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSlug($id)
|
public static function getSlug($id)
|
||||||
{
|
{
|
||||||
return self::get($id)->slug ?? '';
|
return self::get($id)->slug ?? '';
|
||||||
@@ -77,18 +70,6 @@ class TagGroups
|
|||||||
return self::get($id)->name ?? '';
|
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)
|
public static function create($data)
|
||||||
{
|
{
|
||||||
$data['slug'] = Str::slug($data['name']);
|
$data['slug'] = Str::slug($data['name']);
|
||||||
@@ -109,13 +90,13 @@ class TagGroups
|
|||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function destroy($id)
|
|
||||||
{
|
|
||||||
return TagGroup::destroy($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function toggleVisible($id, $visible)
|
public static function toggleVisible($id, $visible)
|
||||||
{
|
{
|
||||||
return self::update(['visible' => $visible], $id);
|
return self::update(['visible' => $visible], $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getModel()
|
||||||
|
{
|
||||||
|
return TagGroup::query();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class Tags
|
|||||||
|
|
||||||
public static function getOptionsFullName()
|
public static function getOptionsFullName()
|
||||||
{
|
{
|
||||||
|
$data = [];
|
||||||
$tags = Tag::with('tag_group')->get()->toArray();
|
$tags = Tag::with('tag_group')->get()->toArray();
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$data[$tag['id']] = $tag['tag_group']['name'].'-'.$tag['name'];
|
$data[$tag['id']] = $tag['tag_group']['name'].'-'.$tag['name'];
|
||||||
@@ -61,7 +62,7 @@ class Tags
|
|||||||
|
|
||||||
public static function store($data)
|
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;
|
return $item->id;
|
||||||
}
|
}
|
||||||
@@ -71,9 +72,8 @@ class Tags
|
|||||||
$data['slug'] = self::buildSlug($data);
|
$data['slug'] = self::buildSlug($data);
|
||||||
$data['group'] = TagGroups::getName($data['tag_group_id']);
|
$data['group'] = TagGroups::getName($data['tag_group_id']);
|
||||||
$data['sort_order'] = self::getNewOrder($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)
|
public static function update($data, $id = false)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user