add shipping rules
This commit is contained in:
@@ -10,7 +10,7 @@ class ApplicationClients
|
||||
public static function associate($client_id, $applications_list)
|
||||
{
|
||||
$applications_existing = self::getApplicationsByClient($client_id);
|
||||
$applications_list = is_array($applications_list) ? $applications_list : array();
|
||||
$applications_list = is_array($applications_list) ? $applications_list : [];
|
||||
|
||||
if (is_array($applications_existing)) {
|
||||
$applications_new = array_diff($applications_list, $applications_existing);
|
||||
@@ -20,9 +20,9 @@ class ApplicationClients
|
||||
$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;
|
||||
|
||||
$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;
|
||||
@@ -42,12 +42,13 @@ class ApplicationClients
|
||||
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 ]);
|
||||
return ApplicationClient::create(['client_id' => $client_id, 'application_id' => $application_id, 'active' => true]);
|
||||
}
|
||||
|
||||
public static function dissociateApplications($client_id, $applications)
|
||||
@@ -56,6 +57,7 @@ class ApplicationClients
|
||||
foreach ($applications as $key => $application_id) {
|
||||
self::dissociateApplication($client_id, $application_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -86,6 +88,6 @@ class ApplicationClients
|
||||
|
||||
public static function isActiveByName($name)
|
||||
{
|
||||
return (!Clients::isClient()) ? true : ApplicationClient::bySlug($name)->byClient(Clients::getId())->first()->active ?? false;
|
||||
return (! Clients::isClient()) ? true : ApplicationClient::bySlug($name)->byClient(Clients::getId())->first()->active ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class ApplicationModules
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ class ApplicationModules
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
@@ -47,7 +49,7 @@ class ApplicationModules
|
||||
{
|
||||
return self::get($id)->name;
|
||||
}
|
||||
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ApplicationModule::findOrFail($id);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core\App;
|
||||
|
||||
use App\Models\Core\App\ApplicationPage;
|
||||
@@ -8,12 +9,14 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Repositories\Core\App;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
use App\Models\Core\App\Application;
|
||||
use App\Repositories\Core\App\ApplicationPages;
|
||||
use App\Repositories\Languages;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class Applications
|
||||
{
|
||||
|
||||
public static function getFullBySlug($slug)
|
||||
{
|
||||
return Application::with('clients')->active()->bySlug($slug)->first();
|
||||
@@ -34,6 +31,7 @@ class Applications
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
@@ -47,6 +45,7 @@ class Applications
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ class Applications
|
||||
{
|
||||
return self::get($id)->name;
|
||||
}
|
||||
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Application::findOrFail($id);
|
||||
@@ -83,6 +82,7 @@ class Applications
|
||||
}
|
||||
$data['langs'] = Languages::getActive();
|
||||
$data['lang'] = Languages::getCurrent();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,13 @@ class Applications
|
||||
return Application::active()->bySlug($slug)->first();
|
||||
}
|
||||
|
||||
public static function toggleActive($id, $active) {
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
}
|
||||
|
||||
public static function toggleVisible($id, $visible) {
|
||||
public static function toggleVisible($id, $visible)
|
||||
{
|
||||
return self::update(['visible' => $visible], $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class Arrays
|
||||
}
|
||||
}
|
||||
unset($array[$oldkey]);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -35,31 +36,32 @@ class Arrays
|
||||
public static function alternate_chunk($array, $parts)
|
||||
{
|
||||
$t = 0;
|
||||
$result = array();
|
||||
$result = [];
|
||||
$max = ceil(count($array) / $parts);
|
||||
foreach (array_chunk($array, $max) as $v) {
|
||||
if ($t < $parts) {
|
||||
$result[] = $v;
|
||||
} else {
|
||||
foreach ($v as $d) {
|
||||
$result[] = array($d);
|
||||
$result[] = [$d];
|
||||
}
|
||||
}
|
||||
$t += count($v);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function fill_chunk($array, $parts)
|
||||
{
|
||||
$t = 0;
|
||||
$result = array_fill(0, $parts - 1, array());
|
||||
$result = array_fill(0, $parts - 1, []);
|
||||
$max = ceil(count($array) / $parts);
|
||||
foreach ($array as $v) {
|
||||
count($result[$t]) >= $max and $t ++;
|
||||
count($result[$t]) >= $max and $t++;
|
||||
$result[$t][] = $v;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Core\Auth\PasswordSecurity;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PasswordSecurities
|
||||
{
|
||||
@@ -16,12 +16,13 @@ class PasswordSecurities
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getUserName($id) {
|
||||
public static function getUserName($id)
|
||||
{
|
||||
return self::getUser($id)->username;
|
||||
}
|
||||
|
||||
public static function getUser($id) {
|
||||
public static function getUser($id)
|
||||
{
|
||||
return PasswordSecurity::with('user')->find($id)->user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\ContextSpecificWords;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\DerivativesOfContextSpecificWords;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\RepetitiveCharacters;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\SequentialCharacters;
|
||||
|
||||
|
||||
|
||||
use App\Repositories\Users;
|
||||
|
||||
class Passwords
|
||||
{
|
||||
public static function validator()
|
||||
@@ -27,9 +14,9 @@ class Passwords
|
||||
$validator->setMinSymbols(3);
|
||||
|
||||
if ($validator->isValid($password)) {
|
||||
printf('password %s is valid' . PHP_EOL, $password);
|
||||
printf('password %s is valid'.PHP_EOL, $password);
|
||||
} else {
|
||||
printf('password %s is invalid' . PHP_EOL, $password);
|
||||
printf('password %s is invalid'.PHP_EOL, $password);
|
||||
var_dump($validator->getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Permission;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
class Permissions
|
||||
{
|
||||
@@ -53,12 +50,14 @@ class Permissions
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -70,6 +69,7 @@ class Permissions
|
||||
public static function create($data)
|
||||
{
|
||||
$permission = Permission::create($data);
|
||||
|
||||
return $permission;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,20 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Core\Auth\Role;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Role;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
|
||||
class Roles
|
||||
{
|
||||
use 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();
|
||||
}
|
||||
|
||||
@@ -32,6 +31,7 @@ class Roles
|
||||
$data['active'] = true;
|
||||
$role = Role::create($data);
|
||||
$role->attachPermissions($permissions);
|
||||
|
||||
return $role;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class Roles
|
||||
$role = self::get($id);
|
||||
$role->update(['name' => $input['name']]);
|
||||
$role->syncPermissions($permissions);
|
||||
|
||||
return $role;
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ class Roles
|
||||
{
|
||||
$role = self::get($id)->toArray();
|
||||
$role['permissions'] = self::get($id)->permissions->pluck('id')->toArray();
|
||||
|
||||
return $role;
|
||||
}
|
||||
|
||||
@@ -89,12 +91,14 @@ class Roles
|
||||
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();
|
||||
|
||||
return RoleUser::byUser($user_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Team;
|
||||
use App\Models\Core\Auth\TeamUser;
|
||||
|
||||
use App\Repositories\Users;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
class Teams
|
||||
{
|
||||
@@ -19,6 +15,7 @@ class Teams
|
||||
public static function getTeamsByUser($user_id = false)
|
||||
{
|
||||
$user_id = $user_id ? $user_id : Users::getId();
|
||||
|
||||
return TeamUser::byUser($user_id);
|
||||
}
|
||||
|
||||
@@ -75,12 +72,14 @@ class Teams
|
||||
public static function getTable($id)
|
||||
{
|
||||
$datas = Team::with(['societe'])->withCount(['users']);
|
||||
|
||||
return Datatables::of($datas)->make(true);
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
Users::destroyByUniqueTeam($id);
|
||||
|
||||
return Team::destroy($id);
|
||||
}
|
||||
|
||||
@@ -97,6 +96,7 @@ class Teams
|
||||
if (isset($data['id']) && $data['id']) {
|
||||
return self::update($data);
|
||||
}
|
||||
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use App\Models\Core\Auth\UserClient;
|
||||
use App\Models\Core\Auth\User;
|
||||
|
||||
use App\Models\Core\Auth\UserClient;
|
||||
use App\Repositories\Clients;
|
||||
|
||||
class UserClients
|
||||
@@ -12,7 +11,7 @@ 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 : array();
|
||||
$clients_list = is_array($clients_list) ? $clients_list : [];
|
||||
|
||||
if (is_array($clients_existing)) {
|
||||
$clients_new = array_diff($clients_list, $clients_existing);
|
||||
@@ -22,9 +21,9 @@ class UserClients
|
||||
$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_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);
|
||||
@@ -41,20 +40,22 @@ class UserClients
|
||||
|
||||
public static function associateClients($user_id, $clients)
|
||||
{
|
||||
$history = "";
|
||||
$history = '';
|
||||
foreach ($clients as $key => $client_id) {
|
||||
$client = Clients::get($client_id);
|
||||
if ($client) {
|
||||
self::associate_client($user_id, $client_id);
|
||||
$history .= $client['name'] . "| ";
|
||||
$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]);
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ class UserClients
|
||||
$password = $user->password;
|
||||
Clients::switchClient($client_id);
|
||||
$client_user = User::on($connection->tenantName())->withTrashed()->where('username', $user->username)->first();
|
||||
if (!$client_user) {
|
||||
if (! $client_user) {
|
||||
$user = $user->toArray();
|
||||
$user['password'] = $password;
|
||||
unset($user['id']);
|
||||
@@ -106,17 +107,19 @@ class UserClients
|
||||
|
||||
public static function dissociateClients($user_id, $clients)
|
||||
{
|
||||
$history = "";
|
||||
$history = '';
|
||||
foreach ($clients as $key => $client_id) {
|
||||
self::dissociate_client($user_id, $client_id);
|
||||
$history .= $client['name'] . "| ";
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,15 @@
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
use App\Models\Core\Auth\User;
|
||||
use App\Repositories\Core\Upload;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
|
||||
|
||||
use App\Models\Core\Auth\User;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
|
||||
use App\Repositories\Core\Upload;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
|
||||
class Users
|
||||
{
|
||||
@@ -27,7 +24,7 @@ class Users
|
||||
public static function getInfo($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
return false;
|
||||
}
|
||||
$user = self::get($id);
|
||||
@@ -36,6 +33,7 @@ class Users
|
||||
$data['avatar'] = self::getAvatar($id);
|
||||
$data['roles'] = $user->roles->pluck('id')->toArray();
|
||||
$data['permissions'] = $user->allPermissions()->pluck('id')->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -46,6 +44,7 @@ class Users
|
||||
}
|
||||
$user = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
$user->roles()->sync(array_keys($data['roles'] ?? []));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -56,6 +55,7 @@ class Users
|
||||
$data['active'] = true;
|
||||
$user = User::create($data);
|
||||
PasswordSecurities::create($user->id);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -64,25 +64,29 @@ class Users
|
||||
$id = $id ? $id : $data['id'];
|
||||
$user = self::get($id);
|
||||
$ret = $user->update($data);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function get($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
|
||||
return User::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getId()
|
||||
{
|
||||
$user = self::getUser();
|
||||
|
||||
return $user ? $user->id : false;
|
||||
}
|
||||
|
||||
public static function getName($id = false)
|
||||
{
|
||||
$user = $id ? self::get($id) : self::getUser();
|
||||
return $user->first_name . ' ' . $user->last_name;
|
||||
|
||||
return $user->first_name.' '.$user->last_name;
|
||||
}
|
||||
|
||||
public static function getUsername($id = false)
|
||||
@@ -108,6 +112,7 @@ class Users
|
||||
public static function delete($id)
|
||||
{
|
||||
$ret = RoleUser::byUser($id)->delete();
|
||||
|
||||
return User::destroy($id);
|
||||
}
|
||||
|
||||
@@ -119,6 +124,7 @@ class Users
|
||||
public static function hasRole($role, $user = false)
|
||||
{
|
||||
$user = $user ? $user : self::getUser();
|
||||
|
||||
return $user ? $user->hasRole($role) : false;
|
||||
}
|
||||
|
||||
@@ -129,14 +135,15 @@ class Users
|
||||
}
|
||||
$user = $user ? $user : self::getUser();
|
||||
$permissions = self::getPermissions($user);
|
||||
|
||||
return $user ? self::checkPermission($permissions, $permission) : false;
|
||||
// TODO why is posing problem ???
|
||||
// return $user ? $user->hasPermission($permission) : false;
|
||||
// return $user ? $user->hasPermission($permission) : false;
|
||||
}
|
||||
|
||||
public static function checkPermission($permissions, $permission)
|
||||
{
|
||||
if (!strpos($permission, '*')) {
|
||||
if (! strpos($permission, '*')) {
|
||||
return in_array($permission, $permissions);
|
||||
}
|
||||
$permission = str_replace('*', '', $permission);
|
||||
@@ -145,12 +152,14 @@ class Users
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getRoles($user = false)
|
||||
{
|
||||
$user = $user ? $user : self::getUser();
|
||||
|
||||
return $user ? $user->roles->pluck('name')->toArray() : false;
|
||||
}
|
||||
|
||||
@@ -158,10 +167,11 @@ class Users
|
||||
{
|
||||
return Roles::getListByRights();
|
||||
}
|
||||
|
||||
|
||||
public static function getPermissions($user = false)
|
||||
{
|
||||
$user = $user ? $user : self::getUser();
|
||||
|
||||
return $user ? $user->allPermissions()->pluck('name')->toArray() : false;
|
||||
}
|
||||
|
||||
@@ -183,11 +193,12 @@ class Users
|
||||
public static function getAvatar($user_id)
|
||||
{
|
||||
$avatar = self::get($user_id)->avatar;
|
||||
if (!$avatar) {
|
||||
if (! $avatar) {
|
||||
return '/assets/img/no-avatar.png';
|
||||
}
|
||||
$path = '/images/avatars/';
|
||||
return $path . $avatar;
|
||||
|
||||
return $path.$avatar;
|
||||
}
|
||||
|
||||
public static function selectOptions()
|
||||
@@ -233,6 +244,7 @@ class Users
|
||||
$file_uploaded = Upload::store($file, $targetDir);
|
||||
$tab = pathinfo($file_uploaded);
|
||||
$response['name'] = $tab['basename'];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -244,6 +256,7 @@ class Users
|
||||
public static function update_password($id, $password)
|
||||
{
|
||||
$password = Hash::make($password);
|
||||
|
||||
return User::find($id)->update(['password' => $password]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,29 +2,30 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use App\Repositories\Core\Arrays;
|
||||
use App\Models\Shop\Category;
|
||||
|
||||
class Categories
|
||||
{
|
||||
|
||||
public static function getFancyTree()
|
||||
{
|
||||
$categories = self::getTree(true);
|
||||
$categories = Arrays::changeKeyName($categories, 'title', 'name');
|
||||
$categories = Arrays::changeKeyName($categories, 'key', 'id');
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
public static function getTreeVisibles($withFolder = false)
|
||||
{
|
||||
$categories = self::getCategoryTreeVisibles()->toArray();
|
||||
|
||||
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
||||
}
|
||||
|
||||
public static function getTree($withFolder = false)
|
||||
{
|
||||
$categories = self::getCategoryTree()->toArray();
|
||||
|
||||
return self::getChildren($categories[0]['children'], $withFolder);
|
||||
}
|
||||
|
||||
@@ -58,6 +59,7 @@ class Categories
|
||||
}
|
||||
// $tree = collect($tree)->sortBy('name')->toArray();
|
||||
$tree = collect($tree)->toArray();
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
@@ -77,15 +79,16 @@ class Categories
|
||||
break;
|
||||
}
|
||||
$category->save();
|
||||
return "1";
|
||||
}
|
||||
|
||||
return '1';
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$parent = ($data['parent_id'] ?? false) ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$category = self::getModel()->create(['name' => $data['name']]);
|
||||
$category->appendToNode($parent)->save();
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
@@ -94,6 +97,7 @@ class Categories
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::getNode($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use BeyondCode\Comments\Comment;
|
||||
use App\Datatables\Admin\Core\CommentsDataTable;
|
||||
use App\Models\Core\Comment as rawComment;
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
|
||||
use App\Datatables\Admin\Core\CommentsDataTable;
|
||||
|
||||
class Comments
|
||||
{
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return rawComment::find($id);
|
||||
@@ -19,12 +16,14 @@ class Comments
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = new CommentsDataTable();
|
||||
|
||||
return $model->html();
|
||||
}
|
||||
|
||||
public static function getCommentsByModel($model, $model_id)
|
||||
{
|
||||
$class = self::getClass($model);
|
||||
|
||||
return self::getCommentsByClass($class, $model_id);
|
||||
}
|
||||
|
||||
@@ -40,14 +39,14 @@ class Comments
|
||||
|
||||
public static function getClass($model)
|
||||
{
|
||||
return 'App\Models\\' . str_replace('.', '\\', $model);
|
||||
return 'App\Models\\'.str_replace('.', '\\', $model);
|
||||
}
|
||||
|
||||
|
||||
public static function getByModel($model)
|
||||
{
|
||||
return $model ? $model->comments->sortByDesc('updated_at')->toArray() : false;
|
||||
}
|
||||
|
||||
|
||||
public static function storeComments($model, $comments)
|
||||
{
|
||||
foreach (($comments ?? []) as $comment) {
|
||||
@@ -66,6 +65,7 @@ class Comments
|
||||
unset($data['_token']);
|
||||
$data['commentable_type'] = Comments::getClass($data['commentable_type']);
|
||||
$data['commentable_id'] = (int) $data['commentable_id'];
|
||||
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class Comments
|
||||
unset($data['id']);
|
||||
$data['is_approved'] = true;
|
||||
$data['user_id'] = Users::getId();
|
||||
|
||||
return rawComment::create($data);
|
||||
}
|
||||
|
||||
@@ -82,6 +83,7 @@ class Comments
|
||||
$id = $id ? $id : $data['id'];
|
||||
$model = self::get($id);
|
||||
$model->update($data);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Collective\Html\Eloquent\Form;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Database
|
||||
{
|
||||
@@ -13,20 +13,21 @@ class Database
|
||||
$data = self::getTableFields($model);
|
||||
foreach ($data as $item) {
|
||||
switch ($item['type']) {
|
||||
case 'integer':
|
||||
$form .= Form::number($item['name']);
|
||||
break;
|
||||
case 'string':
|
||||
$form .= Form::number($item['name']);
|
||||
break;
|
||||
case 'date':
|
||||
$form .= Form::date($item['name']);
|
||||
break;
|
||||
case 'boolean':
|
||||
$form .= Form::checkbox($item['name']);
|
||||
break;
|
||||
case 'integer':
|
||||
$form .= Form::number($item['name']);
|
||||
break;
|
||||
case 'string':
|
||||
$form .= Form::number($item['name']);
|
||||
break;
|
||||
case 'date':
|
||||
$form .= Form::date($item['name']);
|
||||
break;
|
||||
case 'boolean':
|
||||
$form .= Form::checkbox($item['name']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -40,6 +41,7 @@ class Database
|
||||
$type = Schema::getColumnType($table->getTable(), $column);
|
||||
array_push($data, ['name' => $column, 'type' => $type]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class DateCalculation
|
||||
{
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use \Carbon\Carbon;
|
||||
use \League\Period\Period;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DateHelper
|
||||
{
|
||||
@@ -31,17 +30,18 @@ class DateHelper
|
||||
{
|
||||
$quarter = Carbon::now()->quarter;
|
||||
switch ($quarter) {
|
||||
case 1:
|
||||
case 2:
|
||||
$date = Carbon::now()->startOfYear();
|
||||
break;
|
||||
case 3:
|
||||
$date = Carbon::now()->startOfQuarter();
|
||||
break;
|
||||
case 4:
|
||||
$date = Carbon::now()->subMonth(3)->startOfQuarter();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
$date = Carbon::now()->startOfYear();
|
||||
break;
|
||||
case 3:
|
||||
$date = Carbon::now()->startOfQuarter();
|
||||
break;
|
||||
case 4:
|
||||
$date = Carbon::now()->subMonth(3)->startOfQuarter();
|
||||
break;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,11 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use League\Period\Period;
|
||||
use League\Period\Duration;
|
||||
use League\Period\Sequence;
|
||||
use League\Period\Chart\Dataset;
|
||||
use function League\Period\duration;
|
||||
use function League\Period\interval_after;
|
||||
use League\Period\Period;
|
||||
|
||||
class DateRange
|
||||
{
|
||||
|
||||
public static function today()
|
||||
{
|
||||
return self::previousDay(0);
|
||||
@@ -72,6 +67,7 @@ class DateRange
|
||||
foreach ($labels as $label) {
|
||||
$data[$label] = $periods;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -85,6 +81,7 @@ class DateRange
|
||||
$end = $with_actual ? Carbon::now()->endOfMonth() : self::lastMonth();
|
||||
$begin = ($nb == 1) ? $end->copy()->startOfMonth() : $end->copy()->startOfMonth()->subMonth($nb - 1);
|
||||
$t = self::getPeriodsbyMonth($begin, $end);
|
||||
|
||||
return self::getPeriodsbyMonth($begin, $end);
|
||||
}
|
||||
|
||||
@@ -95,6 +92,7 @@ class DateRange
|
||||
$date = self::DatePointToCarbon($period->getStartDate());
|
||||
$months[] = DateTime::getMonthName($date);
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
|
||||
@@ -104,6 +102,7 @@ class DateRange
|
||||
foreach ($periods as $period) {
|
||||
$months[] = DateTime::getMonthName($period['start']);
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
|
||||
@@ -111,6 +110,7 @@ class DateRange
|
||||
{
|
||||
$end = $with_actual ? Carbon::now()->endOfWeek() : self::lastWeek();
|
||||
$begin = $end->copy()->subWeek($nb);
|
||||
|
||||
return self::getPeriodsbyWeek($begin, $end);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ class DateRange
|
||||
{
|
||||
$end = $with_actual ? Carbon::now()->endOfDay() : static::lastDay();
|
||||
$begin = $end->copy()->subDay($nb);
|
||||
|
||||
return self::getPeriodsbyDay($begin, $end);
|
||||
}
|
||||
|
||||
@@ -156,6 +157,7 @@ class DateRange
|
||||
$date = Carbon::now()->subMonth(3)->startOfQuarter();
|
||||
break;
|
||||
}
|
||||
|
||||
return [$date, $date->addMonth(6)];
|
||||
}
|
||||
|
||||
@@ -200,6 +202,7 @@ class DateRange
|
||||
foreach ($period->getDatePeriod($duration) as $day) {
|
||||
$daterange[] = interval_after($day, $duration);
|
||||
}
|
||||
|
||||
return $daterange;
|
||||
}
|
||||
|
||||
@@ -209,6 +212,7 @@ class DateRange
|
||||
foreach ($periods as $period) {
|
||||
$data[] = self::PeriodToCarbon($period);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ trait DateStats
|
||||
{
|
||||
$start = Carbon::now()->startOfMonth($prev);
|
||||
$end = Carbon::now()->endOfMonth($prev);
|
||||
|
||||
return self::countByPeriod($start, $end);
|
||||
}
|
||||
|
||||
@@ -23,12 +24,14 @@ trait DateStats
|
||||
{
|
||||
$start = Carbon::now()->startOfMonth($prev);
|
||||
$end = Carbon::now()->endOfMonth($prev);
|
||||
|
||||
return self::avgByPeriod($start, $end, $field);
|
||||
}
|
||||
|
||||
public static function avgByPeriod($start, $end, $field)
|
||||
{
|
||||
$c = self::countByPeriod($start, $end);
|
||||
|
||||
return $c ? round(self::sumByPeriod($start, $end, $field) / $c, 2) : 0;
|
||||
}
|
||||
|
||||
@@ -36,6 +39,7 @@ trait DateStats
|
||||
{
|
||||
$start = Carbon::now()->startOfMonth($prev);
|
||||
$end = Carbon::now()->endOfMonth($prev);
|
||||
|
||||
return self::sumByPeriod($start, $end, $field);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
use App\Repositories\Languages;
|
||||
|
||||
class DateTime
|
||||
{
|
||||
public static function getMonthName($date, $short = true)
|
||||
@@ -33,22 +31,24 @@ class DateTime
|
||||
public static function DatetoLocale($date = null)
|
||||
{
|
||||
$format = self::getLocaleFormatDate();
|
||||
if (!is_null($date) && !empty($date)) {
|
||||
if (! is_null($date) && ! empty($date)) {
|
||||
$date = Carbon::parse($date)->format($format);
|
||||
} elseif ($date == 'now') {
|
||||
$date = today()->format($format);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public static function DatetimeToLocale($date = null)
|
||||
{
|
||||
$format = self::getLocaleFormatDatetime();
|
||||
if (!is_null($date) && !empty($date)) {
|
||||
if (! is_null($date) && ! empty($date)) {
|
||||
$date = Carbon::parse($date)->format($format);
|
||||
} elseif ($date == 'now') {
|
||||
$date = now()->format($format);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ class DateTime
|
||||
public static function convert($date)
|
||||
{
|
||||
$format = self::getLocaleFormatDate();
|
||||
return !empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD') : null;
|
||||
|
||||
return ! empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD') : null;
|
||||
}
|
||||
|
||||
public static function convertTime($date)
|
||||
@@ -79,17 +80,18 @@ class DateTime
|
||||
if (strlen($date) == 16) {
|
||||
$date .= ':00';
|
||||
}
|
||||
return !empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
|
||||
return ! empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function toFr($date)
|
||||
{
|
||||
return !empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
|
||||
return ! empty($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 ! empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function getYearFromDate($date)
|
||||
@@ -97,10 +99,10 @@ class DateTime
|
||||
// return date_format(DateTime::convert($signature_date), 'Y');
|
||||
$date = DateTime::convert($date);
|
||||
$date = date_create($date);
|
||||
|
||||
return date_format($date, 'Y');
|
||||
}
|
||||
|
||||
|
||||
public static function getLocaleFormatDate()
|
||||
{
|
||||
$locale = self::getLang();
|
||||
@@ -112,6 +114,7 @@ class DateTime
|
||||
default:
|
||||
$format = 'Y-m-d';
|
||||
}
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
@@ -126,6 +129,7 @@ class DateTime
|
||||
default:
|
||||
$format = 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
@@ -157,6 +161,7 @@ class DateTime
|
||||
public static function getISOFormat($format, $date = false)
|
||||
{
|
||||
$date = $date ? $date : now();
|
||||
|
||||
return Carbon::parse($date)->isoFormat($format);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use \League\CLImate\CLImate;
|
||||
use \Timer;
|
||||
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()
|
||||
@@ -28,9 +29,9 @@ class Debug
|
||||
return class_exists('Clockwork\Support\Laravel\ClockworkServiceProvider') ? true : false;
|
||||
}
|
||||
|
||||
public static function start($var = '', $params = array(), $txt = '')
|
||||
public static function start($var = '', $params = [], $txt = '')
|
||||
{
|
||||
if (!static::isDebug()) {
|
||||
if (! static::isDebug()) {
|
||||
return false;
|
||||
}
|
||||
$var = (empty($var)) ? static::getMethod() : $var;
|
||||
@@ -42,7 +43,7 @@ class Debug
|
||||
*/
|
||||
// TODO Fixer la longueur des params string passés
|
||||
if (is_null($params)) {
|
||||
$params = array();
|
||||
$params = [];
|
||||
}
|
||||
|
||||
Timer::start($var, $params);
|
||||
@@ -58,7 +59,7 @@ class Debug
|
||||
|
||||
public static function stop($var = '')
|
||||
{
|
||||
if (!static::isDebug()) {
|
||||
if (! static::isDebug()) {
|
||||
return false;
|
||||
}
|
||||
$var = (empty($var)) ? static::getMethod() : $var;
|
||||
@@ -97,7 +98,7 @@ class Debug
|
||||
/**
|
||||
* dump un message uniquement si debug est true
|
||||
*
|
||||
* @param string $msg [description]
|
||||
* @param string $msg [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function message($msg, $cat = '')
|
||||
@@ -110,7 +111,7 @@ class Debug
|
||||
/**
|
||||
* force la sortie d'un dump, sans passer par la debugbar ou test si debug est true
|
||||
*
|
||||
* @param string $msg [description]
|
||||
* @param string $msg [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function fdump($msg, $cat = '')
|
||||
@@ -122,7 +123,7 @@ class Debug
|
||||
* dump un message suivant le handler de sortie prévu (log, debugbar, cli, ...)
|
||||
*
|
||||
* @param [type] $msg [description]
|
||||
* @param boolean $force si true, force la sortie en output direct
|
||||
* @param bool $force si true, force la sortie en output direct
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function dump($msg, $cat = '', $force = false)
|
||||
@@ -133,18 +134,19 @@ class Debug
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -199,10 +201,11 @@ class Debug
|
||||
$is_debug = false;
|
||||
}
|
||||
} else {
|
||||
dump("la isDebug::165");
|
||||
dump('la isDebug::165');
|
||||
dump($caller);
|
||||
$is_debug = true;
|
||||
}
|
||||
|
||||
return $is_debug;
|
||||
}
|
||||
|
||||
@@ -212,8 +215,8 @@ class Debug
|
||||
$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'] : '';
|
||||
$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);
|
||||
@@ -222,12 +225,12 @@ class Debug
|
||||
|
||||
public static function getLocation()
|
||||
{
|
||||
return static::getMethod() . ' at ' . static::getFile() . ' line ' . static::getLine();
|
||||
return static::getMethod().' at '.static::getFile().' line '.static::getLine();
|
||||
}
|
||||
|
||||
public static function getMethod()
|
||||
{
|
||||
return (static::getClass() . static::getType() . static::getFunction());
|
||||
return static::getClass().static::getType().static::getFunction();
|
||||
}
|
||||
|
||||
public static function getClass()
|
||||
@@ -269,6 +272,7 @@ class Debug
|
||||
while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
|
||||
$k++;
|
||||
}
|
||||
|
||||
return (object) $backtrace[$k];
|
||||
}
|
||||
|
||||
@@ -280,6 +284,7 @@ class Debug
|
||||
while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
|
||||
$k++;
|
||||
}
|
||||
|
||||
return (object) $backtrace[$k - 1];
|
||||
}
|
||||
|
||||
@@ -288,14 +293,15 @@ class Debug
|
||||
$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'])) {
|
||||
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');
|
||||
return PHP_SAPI == 'cli';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,17 @@ namespace App\Repositories\Core;
|
||||
class Export
|
||||
{
|
||||
public $xls;
|
||||
|
||||
public $sheet;
|
||||
|
||||
public $filename;
|
||||
|
||||
public $stockage;
|
||||
|
||||
public $lig;
|
||||
|
||||
public $nb;
|
||||
|
||||
public $debug;
|
||||
|
||||
public function __construct()
|
||||
@@ -75,16 +81,18 @@ class Export
|
||||
if (isset($options[$key])) {
|
||||
$txt = $options[$key][$txt];
|
||||
}
|
||||
if (!isset($multioptions[$key])){
|
||||
$this->writeCell($this->lig, $col, $txt);
|
||||
$this->nb++;
|
||||
$col++;
|
||||
continue;}
|
||||
$tabs = self::getReverseMultiOptions($txt);
|
||||
foreach ($tabs as $key2 => $value) {
|
||||
$txt .= $multioptions[$key][$key2] . '\n';
|
||||
}
|
||||
|
||||
if (! isset($multioptions[$key])) {
|
||||
$this->writeCell($this->lig, $col, $txt);
|
||||
$this->nb++;
|
||||
$col++;
|
||||
|
||||
continue;
|
||||
}
|
||||
$tabs = self::getReverseMultiOptions($txt);
|
||||
foreach ($tabs as $key2 => $value) {
|
||||
$txt .= $multioptions[$key][$key2].'\n';
|
||||
}
|
||||
|
||||
$this->writeCell($this->lig, $col, $txt);
|
||||
$this->nb++;
|
||||
$col++;
|
||||
@@ -104,41 +112,43 @@ class Export
|
||||
{
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="' . $this->filename . '"');
|
||||
header('Content-Disposition: attachment;filename="'.$this->filename.'"');
|
||||
header('Cache-Control: max-age=0');
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
// header('Cache-Control: max-age=1');
|
||||
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
|
||||
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header('Pragma: public'); // HTTP/1.0
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -151,22 +161,25 @@ class Export
|
||||
$c = '';
|
||||
}
|
||||
$c .= chr(65 + $col1);
|
||||
return ($c);
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function getOption($var)
|
||||
{
|
||||
$data = $this->init();
|
||||
return ($data[$var . '_options']);
|
||||
|
||||
return $data[$var.'_options'];
|
||||
}
|
||||
|
||||
public function getOptions($data)
|
||||
{
|
||||
$options = array();
|
||||
$options = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$var = substr($key, 0, -8);
|
||||
$options[$var] = $value;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use SoftCreatR\MimeDetector\MimeDetector;
|
||||
use SoftCreatR\MimeDetector\MimeDetectorException;
|
||||
|
||||
@@ -32,6 +31,7 @@ class File
|
||||
public static function deleteDir($dir)
|
||||
{
|
||||
Storage::deleteDirectory($dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class File
|
||||
try {
|
||||
return (new MimeDetector())->setFile($file)->getFileType();
|
||||
} catch (MimeDetectorException $e) {
|
||||
die('An error occured while trying to load the given file.');
|
||||
exit('An error occured while trying to load the given file.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,25 +6,26 @@ class Geolocation
|
||||
{
|
||||
public static function getCoords($address, $zipcode, $city)
|
||||
{
|
||||
if (!(!empty($address) && !empty($zipcode) && !empty($city))){
|
||||
return;}
|
||||
$address = $address . ' , ' . $city . ' ' . $zipcode . ' , ' . 'France';
|
||||
|
||||
$geocode = app('geocoder')->geocode($address)->get();
|
||||
|
||||
if (!count($geocode)) {
|
||||
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];
|
||||
|
||||
if (! (! empty($address) && ! empty($zipcode) && ! empty($city))) {
|
||||
return;
|
||||
}
|
||||
$address = $address.' , '.$city.' '.$zipcode.' , '.'France';
|
||||
|
||||
$geocode = app('geocoder')->geocode($address)->get();
|
||||
|
||||
if (! count($geocode)) {
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -10,22 +10,22 @@ class HelperDate
|
||||
|
||||
public static function toLocaleFormat($date)
|
||||
{
|
||||
if (!(!is_null($date) && !empty($date))) {
|
||||
if (! (! is_null($date) && ! empty($date))) {
|
||||
return $date;
|
||||
}
|
||||
$locale = session('locale');
|
||||
switch ($locale) {
|
||||
case 'fr':
|
||||
$format = 'd/m/Y';
|
||||
break;
|
||||
case 'en':
|
||||
$format = 'Y-m-d';
|
||||
break;
|
||||
default:
|
||||
$format = 'Y-m-d';
|
||||
case 'fr':
|
||||
$format = 'd/m/Y';
|
||||
break;
|
||||
case 'en':
|
||||
$format = 'Y-m-d';
|
||||
break;
|
||||
default:
|
||||
$format = 'Y-m-d';
|
||||
}
|
||||
$date = Carbon::parse($date)->format($format);
|
||||
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,10 @@ class HelperDate
|
||||
|
||||
public static function frenchDate($d)
|
||||
{
|
||||
if (!$d) {
|
||||
if (! $d) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Carbon::createFromFormat('d/m/Y', $d)->format('Y-m-d');
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ class HelperDate
|
||||
$data[$field] = static::frenchDate($data[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -62,6 +64,7 @@ class HelperDate
|
||||
if ($d && $d != '0000-00-00') {
|
||||
return Carbon::createFromFormat('Y-m-d', $d)->format('d/m/Y');
|
||||
}
|
||||
|
||||
return $d;
|
||||
}
|
||||
|
||||
@@ -72,6 +75,7 @@ class HelperDate
|
||||
$data[$field] = static::toFrenchDate($data[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ use App\Traits\Repository\Imageable;
|
||||
|
||||
class Images
|
||||
{
|
||||
use Imageable;
|
||||
use Imageable;
|
||||
}
|
||||
|
||||
@@ -4,22 +4,23 @@ namespace App\Repositories\Core;
|
||||
|
||||
class Medias
|
||||
{
|
||||
|
||||
public static function getImage($model, $conversion = 'normal', $collection = 'images')
|
||||
{
|
||||
$img = $model->getMedia($collection)->first();
|
||||
|
||||
return $img ? $img->getUrl($conversion) : false;
|
||||
}
|
||||
|
||||
|
||||
public static function getImages($model)
|
||||
{
|
||||
if (!$model) {
|
||||
if (! $model) {
|
||||
return false;
|
||||
}
|
||||
$model->getMedia();
|
||||
foreach ($model->media as $key => $media) {
|
||||
$model->media[$key]['url'] = $media->getUrl();
|
||||
}
|
||||
|
||||
return $model->media;
|
||||
}
|
||||
|
||||
@@ -42,6 +43,7 @@ class Medias
|
||||
public static function deleteImages($model, $collection = 'images')
|
||||
{
|
||||
$ret = $model->clearMediaCollection($collection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,38 +51,41 @@ class Medias
|
||||
{
|
||||
$model->getMedia();
|
||||
$ret = $model->media[$index]->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function buildURL($image, $conversion = '')
|
||||
{
|
||||
return self::getPath($image) . self::getConversion($image, $conversion);
|
||||
return self::getPath($image).self::getConversion($image, $conversion);
|
||||
}
|
||||
|
||||
public static function getPath($image)
|
||||
{
|
||||
$model = basename(str_replace('\\', '/', $image->model_type));
|
||||
return '/storage/' . $model . '/' . $image->collection_name . '/' . $image->id;
|
||||
|
||||
return '/storage/'.$model.'/'.$image->collection_name.'/'.$image->id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static function getExtension($filename)
|
||||
{
|
||||
return '.' . pathinfo($filename, PATHINFO_EXTENSION);
|
||||
return '.'.pathinfo($filename, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
public static function getImageSrc($image)
|
||||
{
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return null;
|
||||
}
|
||||
$id = $image['id'];
|
||||
$filename = self::getFilename($image);
|
||||
|
||||
return "/storage/$id/$filename";
|
||||
}
|
||||
|
||||
@@ -101,13 +106,14 @@ class Medias
|
||||
|
||||
public static function getSrcByType($image, $type)
|
||||
{
|
||||
return $image ? '/storage/' . $image['id'] . '/conversions/' . self::getFilename($image, $type) : false;
|
||||
return $image ? '/storage/'.$image['id'].'/conversions/'.self::getFilename($image, $type) : false;
|
||||
}
|
||||
|
||||
public static function getFilename($image, $type = false)
|
||||
{
|
||||
$image['name'] = self::convertName($image['name']);
|
||||
return $image['name'] . ($type ? '-' . $type : '') . self::getExtension($image['file_name']);
|
||||
|
||||
return $image['name'].($type ? '-'.$type : '').self::getExtension($image['file_name']);
|
||||
}
|
||||
|
||||
public static function convertName($name)
|
||||
|
||||
@@ -6,8 +6,6 @@ use Auth;
|
||||
use Illuminate\Support\Collection;
|
||||
use Lavary\Menu\Builder as LavaryMenuBuilder;
|
||||
|
||||
use App\Repositories\Users;
|
||||
|
||||
/**
|
||||
* Class Builder.
|
||||
*
|
||||
@@ -20,9 +18,8 @@ class Builder extends LavaryMenuBuilder
|
||||
/**
|
||||
* Adds an item to the menu.
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $options
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $options
|
||||
* @return \Lavary\Menu\Item|Item
|
||||
*/
|
||||
public function add($title, $options = '')
|
||||
@@ -65,8 +62,7 @@ class Builder extends LavaryMenuBuilder
|
||||
*
|
||||
* @param $id Id of the menu item to attach to
|
||||
* @param $title Title of the sub item
|
||||
* @param string $options
|
||||
*
|
||||
* @param string $options
|
||||
* @return Lavary\Menu\Item
|
||||
*/
|
||||
public function addTo($id, $title, $options = '')
|
||||
@@ -74,7 +70,7 @@ class Builder extends LavaryMenuBuilder
|
||||
$parent = $this->whereId($id)->first();
|
||||
|
||||
if (isset($parent)) {
|
||||
if (!isset($this->root[$parent->id])) {
|
||||
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);
|
||||
|
||||
@@ -9,7 +9,6 @@ class Item extends LavaryMenuItem
|
||||
/**
|
||||
* Set the item icon using font-awesome.
|
||||
*
|
||||
* @param $icon
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -23,7 +22,6 @@ class Item extends LavaryMenuItem
|
||||
/**
|
||||
* Set the item order.
|
||||
*
|
||||
* @param $order
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -37,29 +35,29 @@ class Item extends LavaryMenuItem
|
||||
/**
|
||||
* Make the item active.
|
||||
*
|
||||
* @param string|array $routes
|
||||
*
|
||||
* @param string|array $routes
|
||||
* @return self
|
||||
*/
|
||||
public function activeIfRoute($routes = null)
|
||||
{
|
||||
if (!empty($routes)) {
|
||||
if (! empty($routes)) {
|
||||
if (is_string($routes)) {
|
||||
$routes = [$routes];
|
||||
}
|
||||
|
||||
foreach ($routes as $pattern) {
|
||||
$arr = [$pattern];
|
||||
if (!if_route_pattern($arr)){
|
||||
continue;}
|
||||
$this->activate();
|
||||
|
||||
if (strstr($this->title, 'circle-o')) {
|
||||
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
|
||||
}
|
||||
// dump($this);
|
||||
return $this;
|
||||
if (! if_route_pattern($arr)) {
|
||||
continue;
|
||||
}
|
||||
$this->activate();
|
||||
|
||||
if (strstr($this->title, 'circle-o')) {
|
||||
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
|
||||
}
|
||||
// dump($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@ class Logs
|
||||
|
||||
$menu->addTo(
|
||||
'logs', __('boilerplate::logs.menu.stats'), [
|
||||
'route' => 'boilerplate.logs.dashboard',
|
||||
'permission' => 'logs', ]
|
||||
'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', ]
|
||||
'route' => 'boilerplate.logs.list',
|
||||
'permission' => 'logs', ]
|
||||
)
|
||||
->order(1120)
|
||||
->activeIfRoute(['boilerplate.logs.list', 'boilerplate.logs.show', 'boilerplate.logs.filter']);
|
||||
|
||||
@@ -9,21 +9,22 @@ class Menu extends LavaryMenu
|
||||
{
|
||||
public function make($name, $callback)
|
||||
{
|
||||
if (!is_callable($callback)){
|
||||
return;}
|
||||
if (!array_key_exists($name, $this->menu)) {
|
||||
$this->menu[$name] = new Builder($name, $this->loadConf($name));
|
||||
}
|
||||
|
||||
// Registering the items
|
||||
call_user_func($callback, $this->menu[$name]);
|
||||
|
||||
// Storing each menu instance in the collection
|
||||
$this->collection->put($name, $this->menu[$name]);
|
||||
|
||||
// Make the instance available in all views
|
||||
View::share($name, $this->menu[$name]);
|
||||
|
||||
return $this->menu[$name];
|
||||
if (! is_callable($callback)) {
|
||||
return;
|
||||
}
|
||||
if (! array_key_exists($name, $this->menu)) {
|
||||
$this->menu[$name] = new Builder($name, $this->loadConf($name));
|
||||
}
|
||||
|
||||
// Registering the items
|
||||
call_user_func($callback, $this->menu[$name]);
|
||||
|
||||
// Storing each menu instance in the collection
|
||||
$this->collection->put($name, $this->menu[$name]);
|
||||
|
||||
// Make the instance available in all views
|
||||
View::share($name, $this->menu[$name]);
|
||||
|
||||
return $this->menu[$name];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,22 +14,22 @@ class Users
|
||||
|
||||
$menu->addTo(
|
||||
'access', __('boilerplate::users.list.title'), [
|
||||
'route' => 'boilerplate.users.index',
|
||||
'permission' => 'users_crud', ]
|
||||
'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', ]
|
||||
'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', ]
|
||||
'route' => 'boilerplate.roles.index',
|
||||
'permission' => 'roles_crud', ]
|
||||
)
|
||||
->activeIfRoute('boilerplate.roles.*');
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Number
|
||||
$formatter->setLanguageManager($languageManager);
|
||||
|
||||
$price = $formatter->format($value, '0,0');
|
||||
|
||||
return $price;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Barryvdh\DomPDF\Facade\Pdf as DomPDF;
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use GravityMedia\Ghostscript\Ghostscript;
|
||||
use Mpdf\Mpdf;
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class PDF
|
||||
@@ -18,15 +18,13 @@ class PDF
|
||||
->waitUntilNetworkIdle()
|
||||
->format('A4')
|
||||
->showBackground()
|
||||
->savePdf("temp.pdf");
|
||||
|
||||
->savePdf('temp.pdf');
|
||||
|
||||
$postRoute = URL::signedRoute('orderinvoices.store', ['order' => $this->order]);
|
||||
Http::attach('invoice', file_get_contents('temp.pdf'), $filename)
|
||||
->post($postRoute)
|
||||
->throw();
|
||||
}
|
||||
catch (\Exception $exception )
|
||||
{
|
||||
} catch (\Exception $exception) {
|
||||
Log::error($exception);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +33,7 @@ class PDF
|
||||
{
|
||||
\Debugbar::disable();
|
||||
$pdf = DomPDF::loadView($view, $data);
|
||||
|
||||
return $pdf->download($filename);
|
||||
}
|
||||
|
||||
@@ -42,12 +41,14 @@ class PDF
|
||||
{
|
||||
$mpdf = new Mpdf();
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
return $mpdf->Output();
|
||||
}
|
||||
|
||||
public static function convertURL($url)
|
||||
{
|
||||
$pdf = SnappyPdf::loadFile($url);
|
||||
|
||||
return $pdf->download('invoice.pdf');
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use Carbon\Carbon;
|
||||
class Stat
|
||||
{
|
||||
public static $is_debug = false;
|
||||
|
||||
public static $force_output = true;
|
||||
|
||||
public static function getNewByPeriod($model, $start, $end)
|
||||
@@ -45,6 +46,7 @@ class Stat
|
||||
$var_option = $var;
|
||||
}
|
||||
$options = self::getOption($var_option);
|
||||
|
||||
return self::getStatsbyMultiOptions($var, $options);
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ class Stat
|
||||
$count = self::getModel()
|
||||
->whereBetween($var, $begin, $end)
|
||||
->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
@@ -64,10 +67,9 @@ class Stat
|
||||
->groupBy($var)
|
||||
->get();
|
||||
// var_Debug::message($data);
|
||||
return ($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public static function getStatsbyOptions($var, $var_option = '')
|
||||
{
|
||||
if (empty($var_option)) {
|
||||
@@ -81,7 +83,7 @@ class Stat
|
||||
$data[] = ['y' => $y, 'name' => $value];
|
||||
}
|
||||
// var_Debug::message($data);
|
||||
return ($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getCountbyOption($var)
|
||||
@@ -98,7 +100,8 @@ class Stat
|
||||
$data[$key] = (int) $data[$key]->nb;
|
||||
}
|
||||
}
|
||||
return ($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getStatsbyMultiOptions($var, $options)
|
||||
@@ -107,7 +110,8 @@ class Stat
|
||||
$nb = self::getCountbyBin($var, $key);
|
||||
$data[] = ['y' => $nb, 'name' => $value];
|
||||
}
|
||||
return ($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getCountbyBin($var, $value)
|
||||
@@ -116,27 +120,28 @@ class Stat
|
||||
$count = self::getModel()
|
||||
->where($var, '&', $bit)
|
||||
->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
public static function getStatsbyPeriod($begin = '', $end = '', $period = 'days')
|
||||
{
|
||||
$end = Carbon::now();
|
||||
$begin = Carbon::now()->subMonth(1);
|
||||
switch ($period) {
|
||||
case 'days':
|
||||
$periods = DateRange::getPeriodsbyDay($begin, $end);
|
||||
break;
|
||||
case 'months':
|
||||
$periods = DateRange::getPeriodsbyMonth($begin, $end);
|
||||
break;
|
||||
case 'weeks':
|
||||
$periods = DateRange::getPeriodsbyWeek($begin, $end);
|
||||
break;
|
||||
default:
|
||||
case 'days':
|
||||
$periods = DateRange::getPeriodsbyDay($begin, $end);
|
||||
break;
|
||||
case 'months':
|
||||
$periods = DateRange::getPeriodsbyMonth($begin, $end);
|
||||
break;
|
||||
case 'weeks':
|
||||
$periods = DateRange::getPeriodsbyWeek($begin, $end);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return ($periods);
|
||||
|
||||
return $periods;
|
||||
}
|
||||
|
||||
public static function serializeValues($tab)
|
||||
@@ -154,7 +159,7 @@ class Stat
|
||||
$tab = $collection->pluck($var)->toArray();
|
||||
}
|
||||
|
||||
return implode(",", $tab);
|
||||
return implode(',', $tab);
|
||||
}
|
||||
|
||||
public static function avgByVar($tab, $var)
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Support\Facades\Storage as Storage2;
|
||||
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
use SoftCreatR\MimeDetector\MimeDetector;
|
||||
use SoftCreatR\MimeDetector\MimeDetectorException;
|
||||
|
||||
class Storage
|
||||
{
|
||||
public static function checkDirOrCreate($dir)
|
||||
@@ -30,18 +26,21 @@ class Storage
|
||||
public static function createDir($dir)
|
||||
{
|
||||
Storage2::makeDirectory($dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteDir($dir)
|
||||
{
|
||||
Storage2::deleteDirectory($dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteFile($file)
|
||||
{
|
||||
Storage2::delete($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,8 +48,8 @@ class Storage
|
||||
{
|
||||
$process = new Process(['srm', $file]);
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
throw new ProcessFailedException($process);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +86,8 @@ class Storage
|
||||
|
||||
public static function getFileType($file)
|
||||
{
|
||||
$file = self::getStoragePath() . $file;
|
||||
$file = self::getStoragePath().$file;
|
||||
|
||||
return File::getFileType($file);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class Tag
|
||||
public static function getTagsByModel($model)
|
||||
{
|
||||
$tags = $model->tags;
|
||||
|
||||
return $tags ? $tags->pluck('id')->toArray() : null;
|
||||
}
|
||||
|
||||
@@ -17,6 +18,7 @@ class Tag
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray() : false;
|
||||
|
||||
return $tags ? $model->syncTags($tags, true) : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class Trees
|
||||
public static function getTree($model)
|
||||
{
|
||||
$tree = $model->orderBy('_lft', 'asc')->get()->toTree()->toArray();
|
||||
|
||||
return self::getChildren($tree[0]['children']);
|
||||
}
|
||||
|
||||
@@ -23,6 +24,7 @@ class Trees
|
||||
}
|
||||
$tree[] = $leaf;
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
@@ -32,25 +34,26 @@ class Trees
|
||||
$item_target = self::getNode($target_id);
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
$item->save();
|
||||
return "1";
|
||||
}
|
||||
|
||||
return '1';
|
||||
}
|
||||
|
||||
public static function create($data, $model)
|
||||
{
|
||||
$parent = (isset($data['parent_id']) && $data['parent_id']) ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$tree = $model->create(['name' => $data['name']]);
|
||||
$tree->appendToNode($parent)->save();
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
@@ -58,6 +61,7 @@ class Trees
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
|
||||
return $item->update(['name' => $data['name']]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image as Image;
|
||||
|
||||
@@ -14,6 +13,7 @@ class Upload
|
||||
$data['filetype'] = $file->getClientOriginalExtension();
|
||||
$data['filesize'] = $file->getSize();
|
||||
$data['mime'] = $file->getMimeType();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class Upload
|
||||
$pos = strrpos($file, '/');
|
||||
$uuid = substr($file, $pos + 1);
|
||||
$uuid = pathinfo($uuid, PATHINFO_FILENAME);
|
||||
|
||||
return $uuid;
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ class Upload
|
||||
// $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;
|
||||
}
|
||||
|
||||
@@ -55,6 +57,7 @@ class Upload
|
||||
{
|
||||
$thumb = self::getThumbPath($file, $sub);
|
||||
$filename = self::getPublicPath($file);
|
||||
|
||||
return Image::make($filename)->orientate()->widen($size)->save($thumb);
|
||||
}
|
||||
|
||||
@@ -63,49 +66,52 @@ class Upload
|
||||
return 'public/' . self::getFilename($file);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public static function getPublicPath($file)
|
||||
{
|
||||
return storage_path('app/public/' . self::getFilename($file));
|
||||
return storage_path('app/public/'.self::getFilename($file));
|
||||
}
|
||||
|
||||
public static function getPrivatePath($file)
|
||||
{
|
||||
return storage_path('app/' . self::getFilename($file));
|
||||
return storage_path('app/'.self::getFilename($file));
|
||||
}
|
||||
|
||||
public static function getSrc($file)
|
||||
{
|
||||
return '/storage/' . self::getFilename($file);
|
||||
return '/storage/'.self::getFilename($file);
|
||||
}
|
||||
|
||||
public static function getThumbPath($file)
|
||||
{
|
||||
return storage_path('app/public/' . self::getThumbFilename($file));
|
||||
return storage_path('app/public/'.self::getThumbFilename($file));
|
||||
}
|
||||
|
||||
public static function getThumbSrc($file)
|
||||
{
|
||||
return '/storage/' . self::getThumbFilename($file);
|
||||
return '/storage/'.self::getThumbFilename($file);
|
||||
}
|
||||
|
||||
public static function getFilename($file)
|
||||
{
|
||||
$file = (is_array($file)) ? (object) $file : $file;
|
||||
return $file->filepath . '/' . self::getName($file);
|
||||
|
||||
return $file->filepath.'/'.self::getName($file);
|
||||
}
|
||||
|
||||
public static function getThumbFilename($file, $sub = false)
|
||||
{
|
||||
$sub = $sub ? $sub : 'thumbs/';
|
||||
$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)
|
||||
{
|
||||
$file = (is_array($file)) ? (object) $file : $file;
|
||||
return $file->uuid . '.' . strtolower($file->filetype);
|
||||
|
||||
return $file->uuid.'.'.strtolower($file->filetype);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,9 +122,10 @@ class Upload
|
||||
*/
|
||||
public static function fix($path)
|
||||
{
|
||||
if (!self::isWindows()) {
|
||||
if (! self::isWindows()) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return str_replace('/', '\\', $path);
|
||||
}
|
||||
|
||||
@@ -127,6 +134,7 @@ class Upload
|
||||
if (Storage::exists($dest)) {
|
||||
self::delete($dest);
|
||||
}
|
||||
|
||||
return Storage::move($source, $dest);
|
||||
}
|
||||
|
||||
@@ -144,9 +152,9 @@ class Upload
|
||||
{
|
||||
return is_dir($path) || mkdir($path, $permissions, true);
|
||||
}
|
||||
|
||||
|
||||
public static function isWindows()
|
||||
{
|
||||
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
|
||||
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@ class Basket
|
||||
public static function first($key)
|
||||
{
|
||||
$data = self::get($key);
|
||||
|
||||
return array_shift($data);
|
||||
}
|
||||
|
||||
public static function last($key)
|
||||
{
|
||||
$data = self::get($key);
|
||||
|
||||
return $data ? array_pop($data) : false;
|
||||
}
|
||||
|
||||
@@ -33,6 +35,7 @@ class Basket
|
||||
array_push($data, $value);
|
||||
self::set($key, $data);
|
||||
}
|
||||
|
||||
return count($data);
|
||||
}
|
||||
|
||||
@@ -42,6 +45,7 @@ class Basket
|
||||
if (($index = array_search($value, $data)) !== false) {
|
||||
unset($data[$index]);
|
||||
}
|
||||
|
||||
return self::set($key, $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ class NewUser extends Notification
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
@@ -25,8 +24,7 @@ class NewUser extends Notification
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
@@ -40,7 +38,7 @@ class NewUser extends Notification
|
||||
->line(
|
||||
__(
|
||||
'notifications.newuser.intro', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -51,7 +49,7 @@ class NewUser extends Notification
|
||||
->salutation(
|
||||
__(
|
||||
'notifications.salutation', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -61,8 +59,7 @@ class NewUser extends Notification
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
|
||||
@@ -9,8 +9,7 @@ class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
/*
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Repositories\Core\User;
|
||||
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use \Cart;
|
||||
use Cart;
|
||||
|
||||
class ShopCart
|
||||
{
|
||||
@@ -20,6 +18,7 @@ class ShopCart
|
||||
} else {
|
||||
self::get()->add($item);
|
||||
}
|
||||
|
||||
return [
|
||||
'count' => self::count(),
|
||||
'quantity' => self::getTotalQuantity(),
|
||||
@@ -45,6 +44,7 @@ class ShopCart
|
||||
public static function clear()
|
||||
{
|
||||
Cart::clear();
|
||||
|
||||
return self::get()->clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\Repositories\Core\User;
|
||||
|
||||
use Darryldecode\Cart\CartCollection;
|
||||
|
||||
use App\Models\Core\CartStorage;
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
use Darryldecode\Cart\CartCollection;
|
||||
|
||||
class ShopCartStorage
|
||||
{
|
||||
@@ -16,11 +14,12 @@ class ShopCartStorage
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if (!$this->has($key)) {
|
||||
if (! $this->has($key)) {
|
||||
return [];
|
||||
}
|
||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||
|
||||
|
||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
@@ -31,7 +30,7 @@ class ShopCartStorage
|
||||
} else {
|
||||
CartStorage::create([
|
||||
'id' => $key,
|
||||
'cart_data' => $value
|
||||
'cart_data' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user