fix devops error
This commit is contained in:
@@ -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()
|
||||
{
|
||||
$validator = new \Password\Validator(new \Password\StringHelper);
|
||||
$validator = new \Password\Validator(new \Password\StringHelper());
|
||||
$validator->setMinLength(5);
|
||||
$validator->setMinLowerCaseLetters(2);
|
||||
$validator->setMinUpperCaseLetters(1);
|
||||
|
||||
@@ -3,83 +3,24 @@
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use App\Models\Core\Auth\Permission;
|
||||
use Yajra\DataTables\DataTables;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Permissions
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getModules()
|
||||
{
|
||||
return Permission::select('module')->distinct('module')->get()->pluck('module');
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Permission::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getInfo($id)
|
||||
{
|
||||
return Permission::find($id);
|
||||
}
|
||||
|
||||
public static function select_all()
|
||||
{
|
||||
return self::getAll()->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_id($id)
|
||||
{
|
||||
return Permission::find($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Permission::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Permission::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
public static function getModel()
|
||||
{
|
||||
return Permission::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Permission::withCount(['users']);
|
||||
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
Users::destroyByUniquePermission($id);
|
||||
|
||||
return Permission::destroy($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return (isset($data['id']) && $data['id']) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$permission = Permission::create($data);
|
||||
|
||||
return $permission;
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return self::get($data['id'])->update($data);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return Permission::count();
|
||||
return Permission::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,26 +4,21 @@ namespace App\Repositories\Core\Auth;
|
||||
|
||||
use App\Models\Core\Auth\Role;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
class Roles
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
use Basic, LaratrustUserTrait;
|
||||
|
||||
public static function getListByRights()
|
||||
{
|
||||
$data = (! Auth::user()->hasRole('admin')) ? Role::whereNotIn('name', ['admin'])->get() : Role::all();
|
||||
$data = ! Auth::user()->hasRole('admin') ? Role::whereNotIn('name', ['admin'])->get() : Role::all();
|
||||
|
||||
return $data->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function store($input)
|
||||
{
|
||||
return (isset($input['id']) && $input['id']) ? self::update($input) : self::create($input);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$permissions = array_keys($data['permissions']);
|
||||
@@ -35,10 +30,9 @@ class Roles
|
||||
return $role;
|
||||
}
|
||||
|
||||
// met à jour les informations d'une forme juridique
|
||||
public static function update($input, $id = false)
|
||||
{
|
||||
$id = ($id) ? $id : $input['id'];
|
||||
$id = $id ? $id : $input['id'];
|
||||
$permissions = array_keys($input['permissions']);
|
||||
$role = self::get($id);
|
||||
$role->update(['name' => $input['name']]);
|
||||
@@ -47,24 +41,11 @@ class Roles
|
||||
return $role;
|
||||
}
|
||||
|
||||
// supprime une forme juridique
|
||||
public static function delete($id)
|
||||
{
|
||||
return Role::destroy($id);
|
||||
}
|
||||
|
||||
// met à jour le statut actif/inactif d'une forme juridique
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return Role::find($id)->update(['active' => $active]);
|
||||
}
|
||||
|
||||
// compte le nombre de formes juridiques
|
||||
public static function count()
|
||||
{
|
||||
return Role::count();
|
||||
}
|
||||
|
||||
public static function getWithPermissions($id)
|
||||
{
|
||||
$role = self::get($id)->toArray();
|
||||
@@ -73,28 +54,11 @@ class Roles
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Role::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Role::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Role::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Role::orderBy('name', 'asc');
|
||||
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function getRolesByUser($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : Users::getId();
|
||||
@@ -112,8 +76,8 @@ class Roles
|
||||
return self::getUsersByRole($id)->pluck('user_id');
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
public static function getModel()
|
||||
{
|
||||
return Role::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
||||
return RoleUser::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
return (self::hasRole('admin')) ? true : false;
|
||||
return self::hasRole('admin');
|
||||
}
|
||||
|
||||
public static function getInfo($id = false)
|
||||
@@ -42,7 +42,7 @@ class Users
|
||||
if ($data['id'] ?? false) {
|
||||
unset($data['password']);
|
||||
}
|
||||
$user = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
$user = $data['id'] ?? false ? self::update($data) : self::create($data);
|
||||
$user->roles()->sync(array_keys($data['roles'] ?? []));
|
||||
|
||||
return $user;
|
||||
@@ -243,9 +243,10 @@ class Users
|
||||
$data = Upload::getData($file);
|
||||
$file_uploaded = Upload::store($file, $targetDir);
|
||||
$tab = pathinfo($file_uploaded);
|
||||
$response['name'] = $tab['basename'];
|
||||
|
||||
return $response;
|
||||
return [
|
||||
'name' => $tab['basename'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function update_avatar($id, $avatar)
|
||||
|
||||
@@ -10,9 +10,8 @@ class Categories
|
||||
{
|
||||
$categories = self::getTree(true);
|
||||
$categories = Arrays::changeKeyName($categories, 'title', 'name');
|
||||
$categories = Arrays::changeKeyName($categories, 'key', 'id');
|
||||
|
||||
return $categories;
|
||||
return Arrays::changeKeyName($categories, 'key', 'id');
|
||||
}
|
||||
|
||||
public static function getTreeVisibles($withFolder = false)
|
||||
@@ -36,7 +35,8 @@ class Categories
|
||||
|
||||
public static function getCategoryTreeVisibles($sale_channel_id = false)
|
||||
{
|
||||
return self::getModel()->defaultOrder()->hasAvailableOffersByCategoryParent($sale_channel_id)->visible()->get()->toTree();
|
||||
return self::getModel()->defaultOrder()
|
||||
->hasAvailableOffersByCategoryParent($sale_channel_id)->visible()->get()->toTree();
|
||||
}
|
||||
|
||||
public static function getChildren($data, $withFolder = false)
|
||||
@@ -46,7 +46,7 @@ class Categories
|
||||
$leaf = [];
|
||||
$leaf['name'] = $item['name'];
|
||||
$leaf['id'] = $item['id'];
|
||||
$children = ($item['children'] ?? false) ? self::getChildren($item['children']) : false;
|
||||
$children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
|
||||
if ($children) {
|
||||
$leaf['children'] = $children;
|
||||
if ($withFolder) {
|
||||
@@ -57,10 +57,8 @@ class Categories
|
||||
}
|
||||
$tree[] = $leaf;
|
||||
}
|
||||
// $tree = collect($tree)->sortBy('name')->toArray();
|
||||
$tree = collect($tree)->toArray();
|
||||
|
||||
return $tree;
|
||||
return collect($tree)->toArray();
|
||||
}
|
||||
|
||||
public static function moveTree($node_id, $target_id, $type)
|
||||
@@ -70,22 +68,21 @@ class Categories
|
||||
|
||||
switch ($type) {
|
||||
case 'after':
|
||||
// dump("$node_id After $target_id");
|
||||
$category->afterNode($category_target);
|
||||
break;
|
||||
case 'inside':
|
||||
// dump("$node_id inside $target_id");
|
||||
$category_target->appendNode($category);
|
||||
break;
|
||||
default:
|
||||
$category->afterNode($category_target);
|
||||
}
|
||||
$category->save();
|
||||
|
||||
return '1';
|
||||
return $category->save();
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$parent = ($data['parent_id'] ?? false) ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$category = self::getModel()->create(['name' => $data['name']]);
|
||||
$category->appendToNode($parent)->save();
|
||||
|
||||
@@ -101,11 +98,6 @@ class Categories
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
// return Category::destroy($id);
|
||||
}
|
||||
|
||||
public static function getRoot()
|
||||
{
|
||||
return self::getNode(1);
|
||||
@@ -119,6 +111,5 @@ class Categories
|
||||
public static function getModel()
|
||||
{
|
||||
return app(Category::class);
|
||||
// return app('rinvex.categories.category');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use League\Period\Period;
|
||||
|
||||
use function League\Period\interval_after;
|
||||
use League\Period\Period;
|
||||
|
||||
class DateRange
|
||||
{
|
||||
@@ -207,11 +206,6 @@ class DateRange
|
||||
$range[] = interval_after($day, $duration);
|
||||
}
|
||||
|
||||
/*
|
||||
foreach ($period->dateRangeForward($duration) as $day) {
|
||||
$daterange[] = interval_after($day, $duration);
|
||||
}
|
||||
*/
|
||||
return $range;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,6 @@ trait DateStats
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return new Model;
|
||||
return new Model();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ class DateTime
|
||||
public static function datetoLocale($date = null)
|
||||
{
|
||||
$format = self::getLocaleFormatDate();
|
||||
if (! is_null($date) && ! empty($date)) {
|
||||
if ($date) {
|
||||
$date = Carbon::parse($date)->format($format);
|
||||
} elseif ($date === 'now') {
|
||||
} else {
|
||||
$date = today()->format($format);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class DateTime
|
||||
public static function datetimeToLocale($date = null)
|
||||
{
|
||||
$format = self::getLocaleFormatDatetime();
|
||||
if (! is_null($date) && ! empty($date)) {
|
||||
if ($date) {
|
||||
$date = Carbon::parse($date)->format($format);
|
||||
} elseif ($date === 'now') {
|
||||
$date = now()->format($format);
|
||||
@@ -82,51 +82,50 @@ class DateTime
|
||||
$date .= ':00';
|
||||
}
|
||||
|
||||
return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
|
||||
return $date ? Carbon::createFromFormat($format, $date) : null;
|
||||
}
|
||||
|
||||
public static function getCarbonDate($date)
|
||||
{
|
||||
$format = self::getLocaleFormatDate();
|
||||
|
||||
return ! empty($date) ? Carbon::createFromFormat($format, $date) : null;
|
||||
return $date ? Carbon::createFromFormat($format, $date) : null;
|
||||
}
|
||||
|
||||
public static function convert($date)
|
||||
{
|
||||
return ! empty($date) ? self::getCarbonDate($date)->isoFormat('Y-MM-DD') : null;
|
||||
return $date ? self::getCarbonDate($date)->isoFormat('Y-MM-DD') : null;
|
||||
}
|
||||
|
||||
public static function convertTime($date)
|
||||
{
|
||||
return ! empty($date) ? self::getCarbonTime($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
return $date ? self::getCarbonTime($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function toLocale($date)
|
||||
{
|
||||
$format = self::getLocaleFormatDate();
|
||||
|
||||
return ! empty($date) ? Carbon::parse($date)->Format($format) : null;
|
||||
return $date ? Carbon::parse($date)->Format($format) : null;
|
||||
}
|
||||
|
||||
public static function toISO($date)
|
||||
{
|
||||
return ! empty($date) ? Carbon::parse($date)->isoFormat('Y-MM-DD') : null;
|
||||
return $date ? Carbon::parse($date)->isoFormat('Y-MM-DD') : null;
|
||||
}
|
||||
|
||||
public static function toFr($date)
|
||||
{
|
||||
return ! empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
|
||||
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
|
||||
}
|
||||
|
||||
public static function toFrTime($date)
|
||||
{
|
||||
return ! empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
|
||||
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function getYearFromDate($date)
|
||||
{
|
||||
// return date_format(DateTime::convert($signature_date), 'Y');
|
||||
$date = self::convert($date);
|
||||
$date = date_create($date);
|
||||
|
||||
|
||||
@@ -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->setSize(12);
|
||||
$styleFont->setName('Arial');
|
||||
// $styleFont->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
|
||||
$this->sheet->setCellValue($coord, $txt);
|
||||
if ($this->debug) {
|
||||
echo "Col $col Ligne $lig : $coord Text $txt<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
public function writeCell($lig, $col, $txt)
|
||||
{
|
||||
$coord = $this->conv($lig, $col);
|
||||
$this->sheet->setCellValue($coord, $txt);
|
||||
if ($this->debug) {
|
||||
echo "Col $col Ligne $lig : $coord Text $txt<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
public function exportRow($data, $config = null)
|
||||
@@ -129,26 +122,20 @@ class Export
|
||||
if ($this->debug) {
|
||||
return;
|
||||
}
|
||||
// Debug::message($this->xls);
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($this->xls, 'Excel2007');
|
||||
// Debug::message($objWriter);
|
||||
// exit;
|
||||
if (! $this->stockage) {
|
||||
$this->header();
|
||||
$objWriter->save('php://output');
|
||||
} else {
|
||||
// $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$objWriter->save('text.xlsx');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function conv($lig, $col)
|
||||
{
|
||||
$c = static::convColtoTxt($col);
|
||||
$lig = $this->lig;
|
||||
|
||||
return "$c$lig";
|
||||
return $c.$lig;
|
||||
}
|
||||
|
||||
public function convColtoTxt($col)
|
||||
|
||||
@@ -6,10 +6,10 @@ class Geolocation
|
||||
{
|
||||
public static function getCoords($address, $zipcode, $city)
|
||||
{
|
||||
if (! (! empty($address) && ! empty($zipcode) && ! empty($city))) {
|
||||
if (! ($address && $zipcode && $city)) {
|
||||
return;
|
||||
}
|
||||
$address = $address.' , '.$city.' '.$zipcode.' , '.'France';
|
||||
$address .= ' , '.$city.' '.$zipcode.' , France';
|
||||
|
||||
$geocode = app('geocoder')->geocode($address)->get();
|
||||
|
||||
@@ -17,15 +17,10 @@ class Geolocation
|
||||
return false;
|
||||
}
|
||||
$res = $geocode[0]->getCoordinates()->toArray();
|
||||
// dump($res);
|
||||
$longitude = $res[0];
|
||||
$latitude = $res[1];
|
||||
|
||||
// dump($latitude);
|
||||
// dump($longitude);
|
||||
// exit;
|
||||
return ['latitude' => $latitude, 'longitude' => $longitude];
|
||||
|
||||
}
|
||||
|
||||
public static function autocomplete($query)
|
||||
|
||||
@@ -8,7 +8,7 @@ class HelperDate
|
||||
{
|
||||
public static function toLocaleFormat($date)
|
||||
{
|
||||
if (! (! is_null($date) && ! empty($date))) {
|
||||
if (! $date) {
|
||||
return $date;
|
||||
}
|
||||
$locale = session('locale');
|
||||
|
||||
@@ -53,9 +53,9 @@ class MailTemplates
|
||||
$m = new Mustache_Engine();
|
||||
|
||||
return $m->render($html_template, $data);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
|
||||
@@ -69,7 +69,6 @@ class Medias
|
||||
|
||||
public static function getConversion($image, $conversion = '')
|
||||
{
|
||||
// return $conversion ? '/conversions/' . $image->name . '-' . $conversion . self::getExtension($image->file_name) : $image->file_name;
|
||||
return $conversion ? '/conversions/'.$image->name.'-'.$conversion.'.jpg' : $image->file_name;
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ class Medias
|
||||
$id = $image['id'];
|
||||
$filename = self::getFilename($image);
|
||||
|
||||
return "/storage/$id/$filename";
|
||||
return "/storage/{$id}/{$filename}";
|
||||
}
|
||||
|
||||
public static function getThumbSrc($image)
|
||||
|
||||
@@ -2,31 +2,18 @@
|
||||
|
||||
namespace App\Repositories\Core\Menu;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Lavary\Menu\Builder as LavaryMenuBuilder;
|
||||
|
||||
/**
|
||||
* Class Builder.
|
||||
*
|
||||
* @property Collection $items;
|
||||
*/
|
||||
class Builder extends LavaryMenuBuilder
|
||||
{
|
||||
private $root = [];
|
||||
|
||||
/**
|
||||
* Adds an item to the menu.
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $options
|
||||
* @return \Lavary\Menu\Item|Item
|
||||
*/
|
||||
public function add($title, $options = '')
|
||||
{
|
||||
$title = sprintf('<span>%s</span>', $title);
|
||||
|
||||
$id = isset($options['id']) ? $options['id'] : $this->id();
|
||||
$id = $options['id'] ?? $this->id();
|
||||
|
||||
$item = new Item($this, $id, $title, $options);
|
||||
|
||||
@@ -37,7 +24,7 @@ class Builder extends LavaryMenuBuilder
|
||||
if (isset($options['role']) || isset($options['permission'])) {
|
||||
$ability = ['admin'];
|
||||
if (isset($options['role'])) {
|
||||
$ability = $ability + explode(',', $options['role']);
|
||||
$ability += explode(',', $options['role']);
|
||||
}
|
||||
|
||||
$permission = null;
|
||||
@@ -57,14 +44,6 @@ class Builder extends LavaryMenuBuilder
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to a existing menu item as a submenu item.
|
||||
*
|
||||
* @param $id Id of the menu item to attach to
|
||||
* @param $title Title of the sub item
|
||||
* @param string $options
|
||||
* @return Lavary\Menu\Item
|
||||
*/
|
||||
public function addTo($id, $title, $options = '')
|
||||
{
|
||||
$parent = $this->whereId($id)->first();
|
||||
@@ -72,8 +51,6 @@ class Builder extends LavaryMenuBuilder
|
||||
if (isset($parent)) {
|
||||
if (! isset($this->root[$parent->id])) {
|
||||
$parent->attr(['url' => '#', 'class' => 'treeview']);
|
||||
// $str = '<span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>';
|
||||
// $parent->append($str);
|
||||
$this->root[$parent->id] = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,6 @@ use Lavary\Menu\Item as LavaryMenuItem;
|
||||
|
||||
class Item extends LavaryMenuItem
|
||||
{
|
||||
/**
|
||||
* Set the item icon using font-awesome.
|
||||
*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function icon($icon)
|
||||
{
|
||||
$this->prepend(sprintf('<i class="%s"></i>', $icon));
|
||||
@@ -19,12 +13,6 @@ class Item extends LavaryMenuItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item order.
|
||||
*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function order($order)
|
||||
{
|
||||
$this->data('order', $order);
|
||||
@@ -32,15 +20,9 @@ class Item extends LavaryMenuItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the item active.
|
||||
*
|
||||
* @param string|array $routes
|
||||
* @return self
|
||||
*/
|
||||
public function activeIfRoute($routes = null)
|
||||
{
|
||||
if (! empty($routes)) {
|
||||
if ($routes) {
|
||||
if (is_string($routes)) {
|
||||
$routes = [$routes];
|
||||
}
|
||||
@@ -56,7 +38,6 @@ class Item extends LavaryMenuItem
|
||||
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
|
||||
}
|
||||
|
||||
// dump($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Sebastienheyd\Boilerplate\Menu;
|
||||
|
||||
use Sebastienheyd\Boilerplate\Menu\Builder as Builder;
|
||||
|
||||
class Logs
|
||||
{
|
||||
public function make(Builder $menu)
|
||||
@@ -12,20 +10,18 @@ class Logs
|
||||
->id('logs')
|
||||
->order(1100);
|
||||
|
||||
$menu->addTo(
|
||||
'logs', __('boilerplate::logs.menu.stats'), [
|
||||
'route' => 'boilerplate.logs.dashboard',
|
||||
'permission' => 'logs', ]
|
||||
)
|
||||
->order(1110)
|
||||
->activeIfRoute('boilerplate.logs.dashboard');
|
||||
$menu->addTo('logs', __('boilerplate::logs.menu.stats'), [
|
||||
'route' => 'boilerplate.logs.dashboard',
|
||||
'permission' => 'logs',
|
||||
])->order(1110)->activeIfRoute('boilerplate.logs.dashboard');
|
||||
|
||||
$menu->addTo(
|
||||
'logs', __('boilerplate::logs.menu.reports'), [
|
||||
'route' => 'boilerplate.logs.list',
|
||||
'permission' => 'logs', ]
|
||||
)
|
||||
->order(1120)
|
||||
->activeIfRoute(['boilerplate.logs.list', 'boilerplate.logs.show', 'boilerplate.logs.filter']);
|
||||
$menu->addTo('logs', __('boilerplate::logs.menu.reports'), [
|
||||
'route' => 'boilerplate.logs.list',
|
||||
'permission' => 'logs',
|
||||
])->order(1120)->activeIfRoute([
|
||||
'boilerplate.logs.list',
|
||||
'boilerplate.logs.show',
|
||||
'boilerplate.logs.filter',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Core\Menu;
|
||||
|
||||
use App\Repositories\Core\Menu\Builder as Builder;
|
||||
|
||||
class Users
|
||||
{
|
||||
public function make(Builder $menu)
|
||||
@@ -12,26 +10,20 @@ class Users
|
||||
->id('access')
|
||||
->order(1000);
|
||||
|
||||
$menu->addTo(
|
||||
'access', __('boilerplate::users.list.title'), [
|
||||
'route' => 'boilerplate.users.index',
|
||||
'permission' => 'users_crud', ]
|
||||
)
|
||||
->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
|
||||
$menu->addTo('access', __('boilerplate::users.list.title'), [
|
||||
'route' => 'boilerplate.users.index',
|
||||
'permission' => 'users_crud',
|
||||
])->activeIfRoute(['boilerplate.users.index', 'boilerplate.users.edit']);
|
||||
|
||||
$menu->addTo(
|
||||
'access', __('boilerplate::users.create.title'), [
|
||||
'route' => 'boilerplate.users.create',
|
||||
'permission' => 'users_crud', ]
|
||||
)
|
||||
->activeIfRoute('boilerplate.users.create');
|
||||
$menu->addTo('access', __('boilerplate::users.create.title'), [
|
||||
'route' => 'boilerplate.users.create',
|
||||
'permission' => 'users_crud',
|
||||
])->activeIfRoute('boilerplate.users.create');
|
||||
|
||||
$menu->addTo(
|
||||
'access', __('boilerplate::layout.role_management'), [
|
||||
'route' => 'boilerplate.roles.index',
|
||||
'permission' => 'roles_crud', ]
|
||||
)
|
||||
->activeIfRoute('boilerplate.roles.*');
|
||||
$menu->addTo('access', __('boilerplate::layout.role_management'), [
|
||||
'route' => 'boilerplate.roles.index',
|
||||
'permission' => 'roles_crud',
|
||||
])->activeIfRoute('boilerplate.roles.*');
|
||||
|
||||
$menu->addTo('access', __('boilerplate::users.profile.title'), ['route' => 'boilerplate.user.profile'])
|
||||
->activeIfRoute('boilerplate.user.profile');
|
||||
|
||||
@@ -9,14 +9,12 @@ class Number
|
||||
{
|
||||
public static function price($value)
|
||||
{
|
||||
$formatter = new Numeral;
|
||||
$languageManager = new LanguageManager;
|
||||
$formatter = new Numeral();
|
||||
$languageManager = new LanguageManager();
|
||||
$languageManager->setCulture('fr-FR');
|
||||
|
||||
$formatter->setLanguageManager($languageManager);
|
||||
|
||||
$price = $formatter->format($value, '0,0');
|
||||
|
||||
return $price;
|
||||
return $formatter->format($value, '0,0');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class Stat
|
||||
|
||||
public static function getStatsbyMultiVar($var, $var_option = '')
|
||||
{
|
||||
if (empty($var_option)) {
|
||||
if ($var_option) {
|
||||
$var_option = $var;
|
||||
}
|
||||
$options = self::getOption($var_option);
|
||||
@@ -52,39 +52,34 @@ class Stat
|
||||
|
||||
public static function getCountByPeriod($var, $begin, $end)
|
||||
{
|
||||
$count = self::getModel()
|
||||
return self::getModel()
|
||||
->whereBetween($var, $begin, $end)
|
||||
->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public static function getCountbyVar($var)
|
||||
{
|
||||
$db = self::getInstance()->app->db;
|
||||
$data = self::getModel()
|
||||
->select($db::raw("count(id) as y, $var as name"))
|
||||
|
||||
return self::getModel()
|
||||
->select($db::raw("count(id) as y, {$var} as name"))
|
||||
->groupBy($var)
|
||||
->get();
|
||||
|
||||
// var_Debug::message($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getStatsbyOptions($var, $var_option = '')
|
||||
{
|
||||
if (empty($var_option)) {
|
||||
if ($var_option ?? false) {
|
||||
$var_option = $var;
|
||||
}
|
||||
$options = self::getInstance()->controller->getOption($var_option);
|
||||
$nb = self::getCountbyOption($var);
|
||||
// var_Debug::message($nb);
|
||||
$data = [];
|
||||
foreach ($options as $key => $value) {
|
||||
$y = (int) $nb[$key];
|
||||
$data[] = ['y' => $y, 'name' => $value];
|
||||
}
|
||||
|
||||
// var_Debug::message($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -108,6 +103,7 @@ class Stat
|
||||
|
||||
public static function getStatsbyMultiOptions($var, $options)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($options as $key => $value) {
|
||||
$nb = self::getCountbyBin($var, $key);
|
||||
$data[] = ['y' => $nb, 'name' => $value];
|
||||
@@ -119,11 +115,8 @@ class Stat
|
||||
public static function getCountbyBin($var, $value)
|
||||
{
|
||||
$bit = pow(2, $value);
|
||||
$count = self::getModel()
|
||||
->where($var, '&', $bit)
|
||||
->count();
|
||||
|
||||
return $count;
|
||||
return self::getModel()->where($var, '&', $bit)->count();
|
||||
}
|
||||
|
||||
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')
|
||||
|
||||
@@ -18,7 +18,7 @@ class Trees
|
||||
$leaf = [];
|
||||
$leaf['name'] = $item['name'];
|
||||
$leaf['id'] = $item['id'];
|
||||
$children = (isset($item['children'])) ? self::getChildren($item['children']) : false;
|
||||
$children = $item['children'] ?? false ? self::getChildren($item['children']) : false;
|
||||
if ($children) {
|
||||
$leaf['children'] = $children;
|
||||
}
|
||||
@@ -35,22 +35,21 @@ class Trees
|
||||
|
||||
switch ($type) {
|
||||
case 'after':
|
||||
// dump("$node_id After $target_id");
|
||||
$item->afterNode($item_target);
|
||||
break;
|
||||
case 'inside':
|
||||
// dump("$node_id inside $target_id");
|
||||
$item_target->appendNode($item);
|
||||
break;
|
||||
default:
|
||||
$item->afterNode($item_target);
|
||||
}
|
||||
$item->save();
|
||||
|
||||
return '1';
|
||||
return $item->save();
|
||||
}
|
||||
|
||||
public static function create($data, $model)
|
||||
{
|
||||
$parent = (isset($data['parent_id']) && $data['parent_id']) ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$tree = $model->create(['name' => $data['name']]);
|
||||
$tree->appendToNode($parent)->save();
|
||||
|
||||
|
||||
@@ -3,38 +3,31 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image as Image;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
class Upload
|
||||
{
|
||||
public static function getData($file)
|
||||
{
|
||||
$data['filename'] = $file->getClientOriginalName();
|
||||
$data['filetype'] = $file->getClientOriginalExtension();
|
||||
$data['filesize'] = $file->getSize();
|
||||
$data['mime'] = $file->getMimeType();
|
||||
|
||||
return $data;
|
||||
return [
|
||||
'filename' => $file->getClientOriginalName(),
|
||||
'filetype' => $file->getClientOriginalExtension(),
|
||||
'filesize' => $file->getSize(),
|
||||
'mime' => $file->getMimeType(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getUuid($file, $data)
|
||||
{
|
||||
$data = (is_array($data)) ? (object) $data : $data;
|
||||
$data = is_array($data) ? (object) $data : $data;
|
||||
$pos = strrpos($file, '/');
|
||||
$uuid = substr($file, $pos + 1);
|
||||
$uuid = pathinfo($uuid, PATHINFO_FILENAME);
|
||||
|
||||
return $uuid;
|
||||
return pathinfo($uuid, PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
public static function storeByVar($var, $path, $public = false)
|
||||
{
|
||||
// check if filename exists
|
||||
// store
|
||||
// Storage::disk('local')->put('file.txt', 'Contents');
|
||||
// $path = Storage::putFile('avatars', $request->file('avatar'));
|
||||
// $path = $request->file('avatar')->storeAs('avatars',$request->user()->id,'s3');
|
||||
// $path = $request->file('avatar')->storePublicly('avatars', 's3');
|
||||
$request = Request();
|
||||
|
||||
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
|
||||
@@ -43,14 +36,11 @@ class Upload
|
||||
public static function store($file, $path)
|
||||
{
|
||||
return Storage::putFile($path, $file);
|
||||
// return $file->store($filepath);
|
||||
}
|
||||
|
||||
public static function storePublic($file, $filepath)
|
||||
{
|
||||
return Storage::putFile($filepath, $file, 'public');
|
||||
// $filepath = 'public/' . $filepath;
|
||||
// return $file->store($filepath);
|
||||
}
|
||||
|
||||
public static function createThumb($file, $size, $sub = false)
|
||||
@@ -61,12 +51,6 @@ class Upload
|
||||
return Image::make($filename)->orientate()->widen($size)->save($thumb);
|
||||
}
|
||||
|
||||
/*
|
||||
public static function getPath($file) {
|
||||
return 'public/' . self::getFilename($file);
|
||||
}
|
||||
*/
|
||||
|
||||
public static function getPublicPath($file)
|
||||
{
|
||||
return storage_path('app/public/'.self::getFilename($file));
|
||||
@@ -94,7 +78,7 @@ class Upload
|
||||
|
||||
public static function getFilename($file)
|
||||
{
|
||||
$file = (is_array($file)) ? (object) $file : $file;
|
||||
$file = is_array($file) ? (object) $file : $file;
|
||||
|
||||
return $file->filepath.'/'.self::getName($file);
|
||||
}
|
||||
@@ -102,24 +86,18 @@ class Upload
|
||||
public static function getThumbFilename($file, $sub = false)
|
||||
{
|
||||
$sub = $sub ? $sub : 'thumbs/';
|
||||
$file = (is_array($file)) ? (object) $file : $file;
|
||||
$file = is_array($file) ? (object) $file : $file;
|
||||
|
||||
return $file->filepath.'/'.$sub.self::getName($file);
|
||||
}
|
||||
|
||||
public static function getName($file)
|
||||
{
|
||||
$file = (is_array($file)) ? (object) $file : $file;
|
||||
$file = is_array($file) ? (object) $file : $file;
|
||||
|
||||
return $file->uuid.'.'.strtolower($file->filetype);
|
||||
}
|
||||
|
||||
/**
|
||||
* [fix problem path with Storage on Windows]
|
||||
*
|
||||
* @param [type] $path [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function fix($path)
|
||||
{
|
||||
if (! self::isWindows()) {
|
||||
|
||||
@@ -42,7 +42,8 @@ class Basket
|
||||
public static function remove($key, $value)
|
||||
{
|
||||
$data = self::get($key);
|
||||
if (($index = array_search($value, $data)) !== false) {
|
||||
$index = array_search($value, $data);
|
||||
if ($index !== false) {
|
||||
unset($data[$index]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,67 +5,45 @@ namespace App\Repositories\Core\User\Notifications;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class NewUser extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$currentUser = \Auth::user();
|
||||
$currentUser = Auth::user();
|
||||
|
||||
return (new MailMessage())
|
||||
->markdown('notifications.email')
|
||||
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
|
||||
->subject(__('notifications.newuser.subject', ['name' => config('app.name')]))
|
||||
->line(
|
||||
__(
|
||||
'notifications.newuser.intro', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]
|
||||
)
|
||||
__('notifications.newuser.intro', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
])
|
||||
)
|
||||
->action(
|
||||
__('notifications.newuser.button'),
|
||||
route('users.firstlogin', $notifiable->remember_token)
|
||||
)
|
||||
->salutation(
|
||||
__(
|
||||
'notifications.salutation', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]
|
||||
)
|
||||
__('notifications.salutation', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
])
|
||||
)
|
||||
->line(__('notifications.newuser.outro'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,6 @@ use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
||||
{
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
/*
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
@@ -26,5 +19,4 @@ class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
||||
)
|
||||
->line(__('notifications.resetpassword.outro'));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ class ShopCartStorage
|
||||
}
|
||||
|
||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
{
|
||||
if ($row = CartStorage::find($key)) {
|
||||
$row = CartStorage::find($key);
|
||||
if ($row) {
|
||||
$row->cart_data = $value;
|
||||
$row->save();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user