Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cd6fc2aa6 |
82 changed files with 662 additions and 361 deletions
|
|
@ -5,9 +5,7 @@ namespace App\Auth;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use Illuminate\Auth\EloquentUserProvider;
|
use Illuminate\Auth\EloquentUserProvider;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
|
||||||
use Illuminate\Contracts\Auth\UserProvider as UserProviderContract;
|
use Illuminate\Contracts\Auth\UserProvider as UserProviderContract;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
@ -34,11 +32,11 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
||||||
* @param array $credentials
|
* @param array $credentials
|
||||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||||
*/
|
*/
|
||||||
public function retrieveByCredentials(array $credentials)
|
public function retrieveByCredentials(array $credentials): \Illuminate\Contracts\Auth\Authenticatable|null
|
||||||
{
|
{
|
||||||
// * Let laravel find a model
|
// * Let laravel find a model
|
||||||
$model = parent::retrieveByCredentials($credentials) ??
|
$model = parent::retrieveByCredentials($credentials) ??
|
||||||
static::retrieveTrashed($credentials);
|
self::retrieveTrashed($credentials);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||||
|
|
@ -77,14 +75,14 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
||||||
*
|
*
|
||||||
* @param UserContract $model
|
* @param UserContract $model
|
||||||
* @param array $credentials
|
* @param array $credentials
|
||||||
* @return boolean
|
* @return boolean|null
|
||||||
* @throws \RuntimeException If model provided is not a Customer or connection to server fails.
|
* @throws \RuntimeException If model provided is not a Customer or connection to server fails.
|
||||||
* @throws \LDC\LDCCRM\Exceptions\CrmException On CRM call error.
|
* @throws \LDC\LDCCRM\Exceptions\CrmException On CRM call error.
|
||||||
* @throws \Exception On CRM call error.
|
* @throws \Exception On CRM call error.
|
||||||
*/
|
*/
|
||||||
public function validateCredentials(UserContract $model, array $credentials)
|
public function validateCredentials(UserContract $model, array $credentials): bool|null
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Database\Eloquent\Model $model */
|
/** @var \App\Models\Customer $model */
|
||||||
if (\get_class($model) !== $this->usedModel) {
|
if (\get_class($model) !== $this->usedModel) {
|
||||||
throw new \RuntimeException('Cannot authenticate any thing else than ' . $this->usedModel);
|
throw new \RuntimeException('Cannot authenticate any thing else than ' . $this->usedModel);
|
||||||
}
|
}
|
||||||
|
|
@ -135,9 +133,9 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
* @throws \Throwable If saving to DB failed.
|
* @throws \Throwable If saving to DB failed.
|
||||||
*/
|
*/
|
||||||
private function createLocalCustomer(\LDC\LDCCRM\Models\Customer $crmCustomer): Model
|
private function createLocalCustomer(\LDC\LDCCRM\Models\Customer $crmCustomer): \Illuminate\Database\Eloquent\Model
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Database\Eloquent\Model $model */
|
/** @var \App\Models\Customer $model */
|
||||||
$model = $this->usedModel::firstOrNew([
|
$model = $this->usedModel::firstOrNew([
|
||||||
'email' => $crmCustomer->email
|
'email' => $crmCustomer->email
|
||||||
]);
|
]);
|
||||||
|
|
@ -155,7 +153,7 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
||||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||||
* @throws \ErrorException If cannot connect to LDAP.
|
* @throws \ErrorException If cannot connect to LDAP.
|
||||||
*/
|
*/
|
||||||
private function retrieveTrashed(array $credentials): ?Authenticatable
|
private function retrieveTrashed(array $credentials): ?\Illuminate\Contracts\Auth\Authenticatable
|
||||||
{
|
{
|
||||||
// * Make changes
|
// * Make changes
|
||||||
if (empty($credentials)) {
|
if (empty($credentials)) {
|
||||||
|
|
@ -173,7 +171,7 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \App\Models\Customer|null $customer */
|
/** @var \App\Models\Customer|null $query */
|
||||||
return $query->withTrashed()->first();
|
return $query->withTrashed()->first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class ReactivateCustomerProvider extends EloquentUserProvider implements UserPro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \App\Models\Customer|null $customer */
|
/** @var \App\Models\Customer|null $query */
|
||||||
return $query->withTrashed()->first();
|
return $query->withTrashed()->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,10 +58,9 @@ class ReactivateCustomerProvider extends EloquentUserProvider implements UserPro
|
||||||
throw new \ErrorException('Cannot authenticate any thing else than ' . Customer::class);
|
throw new \ErrorException('Cannot authenticate any thing else than ' . Customer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plain = $credentials['password'];
|
|
||||||
|
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
if ($this->hasher->check($plain, $customer->getAuthPassword())) {
|
// @phpstan-ignore-next-line
|
||||||
|
if ($this->hasher->check($credentials['password'], $customer->getAuthPassword())) {
|
||||||
// * Restore customer
|
// * Restore customer
|
||||||
return boolval($customer->restore());
|
return boolval($customer->restore());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,35 +28,35 @@ class UserCreate extends Command
|
||||||
/**
|
/**
|
||||||
* The first name of the new user.
|
* The first name of the new user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $first_name;
|
protected $first_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last name of the new user.
|
* The last name of the new user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $last_name;
|
protected $last_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The email of the new user.
|
* The email of the new user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $email;
|
protected $email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The password of the new user.
|
* The password of the new user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $password;
|
protected $password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The role of the new user.
|
* The role of the new user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $role;
|
protected $role;
|
||||||
|
|
||||||
|
|
@ -221,7 +221,7 @@ class UserCreate extends Command
|
||||||
$this->role = $tmp;
|
$this->role = $tmp;
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$this->error(sprintf(
|
$this->error(sprintf(
|
||||||
'Please choose from the selection',
|
'Please choose from the selection %s',
|
||||||
\implode(',', collect($e->errors())->flatten()->all())
|
\implode(',', collect($e->errors())->flatten()->all())
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ enum ActivityLogsEventEnum: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::created->name => 'Création',
|
self::created->name => 'Création',
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ enum ObjectEnum: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::reclaim->name => 'Réclamation',
|
self::reclaim->name => 'Réclamation',
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,8 @@ enum Country: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::afghanistan->name => 'Afghanistan',
|
self::afghanistan->name => 'Afghanistan',
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,7 @@ enum InputType: int
|
||||||
case string = 11;
|
case string = 11;
|
||||||
case text = 12;
|
case text = 12;
|
||||||
case url = 13;
|
case url = 13;
|
||||||
/** Vimeo only */
|
|
||||||
case videoVimeo = 14;
|
case videoVimeo = 14;
|
||||||
/** Youtube only */
|
|
||||||
case videoYoutube = 15;
|
case videoYoutube = 15;
|
||||||
/** Youtube or Vimeo. */
|
|
||||||
case video = 16;
|
case video = 16;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ enum NutriscoreEnum: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition.
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::a->name => 'A',
|
self::a->name => 'A',
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ enum StaticPageType: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition.
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::contact->name => 'Contact',
|
self::contact->name => 'Contact',
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ enum BootstrapThemeEnum: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::light->name => 'Light',
|
self::light->name => 'Light',
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ enum RoleEnum: int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition.
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::conceptor->name => 'Concepteur',
|
self::conceptor->name => 'Concepteur',
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class ActivityLogController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\ActivityLog $activity_log
|
* @param \App\Models\ActivityLog $activity_log
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
|
public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class CommitmentPageController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\CommitmentPage $commitmentPage
|
* @param \App\Models\CommitmentPage $commitmentPage
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(CommitmentPage $commitmentPage): \Illuminate\Contracts\View\View
|
public function edit(CommitmentPage $commitmentPage): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class GameController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\Game $game
|
* @param \App\Models\Game $game
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(Game $game): \Illuminate\Contracts\View\View
|
public function edit(Game $game): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class HistoricalMilestoneController extends Controller
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param \App\Http\Requests\Bo\HistoricalMilestone\StoreHistoricalMilestoneRequest $request
|
* @param \App\Http\Requests\Bo\HistoricalMilestones\StoreHistoricalMilestoneRequest $request
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(StoreHistoricalMilestoneRequest $request): \Illuminate\Http\RedirectResponse
|
public function store(StoreHistoricalMilestoneRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
|
@ -100,7 +100,7 @@ class HistoricalMilestoneController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\HistoricalMilestone $historicalMilestone
|
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
public function edit(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
||||||
|
|
@ -111,7 +111,7 @@ class HistoricalMilestoneController extends Controller
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*
|
*
|
||||||
* @param \App\Http\Requests\Bo\HistoricalMilestone\UpdateHistoricalMilestoneRequest $request
|
* @param \App\Http\Requests\Bo\HistoricalMilestones\UpdateHistoricalMilestoneRequest $request
|
||||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class KlubBlocController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\KlubBloc $klubBloc
|
* @param \App\Models\KlubBloc $klubBloc
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(KlubBloc $klubBloc): \Illuminate\Contracts\View\View
|
public function edit(KlubBloc $klubBloc): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class LocalCommitmentController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\LocalCommitment $localCommitment
|
* @param \App\Models\LocalCommitment $localCommitment
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(LocalCommitment $localCommitment): \Illuminate\Contracts\View\View
|
public function edit(LocalCommitment $localCommitment): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class NewsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\News $news
|
* @param \App\Models\News $news
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(News $news): \Illuminate\Contracts\View\View
|
public function edit(News $news): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class PictoController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\Picto $picto
|
* @param \App\Models\Picto $picto
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(Picto $picto): \Illuminate\Contracts\View\View
|
public function edit(Picto $picto): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class ProductController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\Product $product
|
* @param \App\Models\Product $product
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(Product $product): \Illuminate\Contracts\View\View
|
public function edit(Product $product): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class RangeController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\Range $range
|
* @param \App\Models\Range $range
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(Range $range): \Illuminate\Contracts\View\View
|
public function edit(Range $range): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class StaticPageController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\StaticPage $static_page
|
* @param \App\Models\StaticPage $static_page
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View
|
public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class UserController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param App\Models\User $user
|
* @param \App\Models\User $user
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(User $user): \Illuminate\Contracts\View\View
|
public function edit(User $user): \Illuminate\Contracts\View\View
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ class Controller extends BaseController
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
// Get models with relation's name/label.
|
// Get models with relation's name/label.
|
||||||
if (Str::endsWith($field, '_id') && $query->getModel()->has(Str::remove('_id', $field))) {
|
if (Str::endsWith($field, '_id')) {
|
||||||
$query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) {
|
$query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) {
|
||||||
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
|
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
|
||||||
$queryRelation->where('name', 'like', '%' . $search . '%');
|
$queryRelation->where('name', 'like', '%' . $search . '%');
|
||||||
|
|
@ -132,12 +132,15 @@ class Controller extends BaseController
|
||||||
*/
|
*/
|
||||||
protected function getSearchValue(Builder $query, string $search, string $field): string|array
|
protected function getSearchValue(Builder $query, string $search, string $field): string|array
|
||||||
{
|
{
|
||||||
|
$cast = $query->getModel()->getCasts()[$field] ?? null;
|
||||||
if (
|
if (
|
||||||
count($query->getModel()->getCasts()) and // Check if the model has casts.
|
count($query->getModel()->getCasts()) and // Check if the model has casts.
|
||||||
isset($query->getModel()->getCasts()[$field]) and // Check if there is cast about specific field.
|
$cast and // Check if there is cast about specific field.
|
||||||
enum_exists($query->getModel()->getCasts()[$field]) // Check if the cast is an enum.
|
enum_exists($cast) // Check if the cast is an enum.
|
||||||
) {
|
) {
|
||||||
$cases = collect($query->getModel()->getCasts()[$field]::toArray());
|
/** @var \App\Traits\Enums $cast */
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
|
$cases = collect($cast::toArray());
|
||||||
$enum = $cases->filter(function ($item) use ($search) {
|
$enum = $cases->filter(function ($item) use ($search) {
|
||||||
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
|
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
|
||||||
});
|
});
|
||||||
|
|
@ -158,12 +161,12 @@ class Controller extends BaseController
|
||||||
{
|
{
|
||||||
$rName = request()->route()->getName();
|
$rName = request()->route()->getName();
|
||||||
$table = $query->getModel()->getTable();
|
$table = $query->getModel()->getTable();
|
||||||
if (request()->sort_col) {
|
if (request()->input('sort_col')) {
|
||||||
Session::put("$rName.sort_col", request()->sort_col);
|
Session::put("$rName.sort_col", request()->input('sort_col'));
|
||||||
Session::put("$rName.sorted", true);
|
Session::put("$rName.sorted", true);
|
||||||
}
|
}
|
||||||
if (request()->sort_way) {
|
if (request()->input('sort_way')) {
|
||||||
Session::put("$rName.sort_way", request()->sort_way);
|
Session::put("$rName.sort_way", request()->input('sort_way'));
|
||||||
Session::put("$rName.sorted", true);
|
Session::put("$rName.sorted", true);
|
||||||
}
|
}
|
||||||
if (request()->rst) {
|
if (request()->rst) {
|
||||||
|
|
@ -171,12 +174,16 @@ class Controller extends BaseController
|
||||||
Session::remove("$rName.sort_col");
|
Session::remove("$rName.sort_col");
|
||||||
Session::remove("$rName.sort_way");
|
Session::remove("$rName.sort_way");
|
||||||
}
|
}
|
||||||
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
|
|
||||||
if (
|
if (
|
||||||
!isset($ignore) or
|
request()->input('sort_col') and
|
||||||
(isset($ignore) and !in_array(request()->sort_col, $ignore))
|
request()->input('sort_way') and
|
||||||
|
Schema::hasColumn($table, request()->input('sort_col'))
|
||||||
) {
|
) {
|
||||||
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
|
if (!in_array(request()->input('sort_col'), $ignore)) {
|
||||||
|
$query = $query->orderBy(
|
||||||
|
\sprintf("$table.%s", request()->input('sort_col')),
|
||||||
|
request()->input('sort_way')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} elseif (Schema::hasColumn($table, 'order')) {
|
} elseif (Schema::hasColumn($table, 'order')) {
|
||||||
$query = $query->orderBy('order', 'ASC');
|
$query = $query->orderBy('order', 'ASC');
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Controllers\Fo\Auth;
|
namespace App\Http\Controllers\Fo\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
@ -25,9 +24,9 @@ class ConfirmPasswordController extends Controller
|
||||||
/**
|
/**
|
||||||
* Display the password confirmation view.
|
* Display the password confirmation view.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function showConfirmForm(): View
|
public function showConfirmForm(): \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||||
{
|
{
|
||||||
if (Auth::guard('frontend')->check()) {
|
if (Auth::guard('frontend')->check()) {
|
||||||
return \response()->redirectToRoute('home');
|
return \response()->redirectToRoute('home');
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class ForgotPasswordController extends Controller
|
||||||
use SendsPasswordResetEmails;
|
use SendsPasswordResetEmails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message to user
|
* Message to user.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ class LoginController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function authenticated(Request $request, Model $user): void
|
protected function authenticated(Request $request, Model $user): void
|
||||||
{
|
{
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$user->last_connection = \now();
|
$user->last_connection = \now();
|
||||||
$user->saveOrFail();
|
$user->saveOrFail();
|
||||||
Session::flash('info', trans('Vous êtes à présent connecté'));
|
Session::flash('info', trans('Vous êtes à présent connecté'));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Auth\Events\PasswordReset;
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
@ -47,9 +46,9 @@ class ResetPasswordController extends Controller
|
||||||
* If no token is present, display the link request form.
|
* If no token is present, display the link request form.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function showResetForm(Request $request): View
|
public function showResetForm(Request $request): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
$token = $request->route()->parameter('token');
|
$token = $request->route()->parameter('token');
|
||||||
|
|
||||||
|
|
@ -68,9 +67,6 @@ class ResetPasswordController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function resetPassword(mixed $customer, mixed $password): void
|
protected function resetPassword(mixed $customer, mixed $password): void
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
|
||||||
/** @var string $password */
|
|
||||||
|
|
||||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||||
$crm = app('crmAPI');
|
$crm = app('crmAPI');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,16 @@ class CommitmentController extends Controller
|
||||||
->with('pictos', fn (BelongsToMany $q) => $q->where('published', true))->firstOrFail();
|
->with('pictos', fn (BelongsToMany $q) => $q->where('published', true))->firstOrFail();
|
||||||
|
|
||||||
/** @var \App\Models\StaticPage $staticPageModel */
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
$staticPage = StaticPage::query()->where('type', StaticPageType::commitments)->firstOrFail();
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::commitments)->firstOrFail();
|
||||||
|
|
||||||
/** @var \App\Models\LocalCommitment $localCommitmentModel */
|
/** @var \App\Models\LocalCommitment $localCommitmentModels */
|
||||||
$localCommitments = LocalCommitment::query()
|
$localCommitmentModels = LocalCommitment::query()
|
||||||
->where('published', true)
|
->where('published', true)
|
||||||
->limit(2)->get();
|
->limit(2)->get();
|
||||||
|
|
||||||
return view('fo.pages.commitments', [
|
return view('fo.pages.commitments', [
|
||||||
'staticPageModel' => $staticPage,
|
'staticPageModel' => $staticPageModel,
|
||||||
'localCommitmentList' => $localCommitments,
|
'localCommitmentList' => $localCommitmentModels,
|
||||||
'commitmentPageModel' => $commitmentPage,
|
'commitmentPageModel' => $commitmentPage,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,13 @@ class ContactController extends Controller
|
||||||
*/
|
*/
|
||||||
public function contact(): View
|
public function contact(): View
|
||||||
{
|
{
|
||||||
$products = Product::all();
|
/** @var \App\Models\Product $productModels */
|
||||||
|
$productModels = Product::all();
|
||||||
|
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::contact)->firstOrFail();
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::contact)->firstOrFail();
|
||||||
|
|
||||||
return view('fo.pages.contact', compact('products', 'staticPageModel'));
|
return view('fo.pages.contact', compact('productModels', 'staticPageModel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,19 @@ class HomeController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index(): \Illuminate\Contracts\View\View
|
public function index(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\Range $rangeModels */
|
||||||
$rangeModels = Range::query()->limit(3)->inRandomOrder()->get();
|
$rangeModels = Range::query()->limit(3)->inRandomOrder()->get();
|
||||||
|
|
||||||
|
/** @var \App\Models\News $newsModels */
|
||||||
$newsModels = News::query()->where('published', true)->orderBy('created_at', 'desc')->limit(6)->get();
|
$newsModels = News::query()->where('published', true)->orderBy('created_at', 'desc')->limit(6)->get();
|
||||||
|
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\KlubBloc|null $klubBloc */
|
||||||
$klubBloc = KlubBloc::query()->first();
|
$klubBloc = KlubBloc::query()->first();
|
||||||
|
|
||||||
\throw_if(empty($klubBloc), 'empty klubBloc');
|
\throw_if(is_null($klubBloc), 'empty klubBloc');
|
||||||
|
|
||||||
return view('fo.pages.home', compact('staticPageModel', 'rangeModels', 'klubBloc', 'newsModels'));
|
return view('fo.pages.home', compact('staticPageModel', 'rangeModels', 'klubBloc', 'newsModels'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use App\Http\Requests\Fo\Customers\UpdateAccountRequest;
|
||||||
use App\Http\Requests\Fo\Customers\UpdatePasswordRequest;
|
use App\Http\Requests\Fo\Customers\UpdatePasswordRequest;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use Illuminate\Auth\Events\PasswordReset;
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
@ -22,7 +21,7 @@ class CustomerController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function profile(): View
|
public function profile(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
@ -53,7 +52,7 @@ class CustomerController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||||
*/
|
*/
|
||||||
public function password()
|
public function password(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||||
{
|
{
|
||||||
return view('fo.auth.passwords.change');
|
return view('fo.auth.passwords.change');
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +63,7 @@ class CustomerController extends Controller
|
||||||
* @param \App\Http\Requests\Fo\Customers\UpdatePasswordRequest $request
|
* @param \App\Http\Requests\Fo\Customers\UpdatePasswordRequest $request
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function passwordSubmit(UpdatePasswordRequest $request): RedirectResponse
|
public function passwordSubmit(UpdatePasswordRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer */
|
/** @var \App\Models\Customer */
|
||||||
$customer = \auth('frontend')->user();
|
$customer = \auth('frontend')->user();
|
||||||
|
|
@ -85,7 +84,7 @@ class CustomerController extends Controller
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws \Illuminate\Validation\ValidationException If something failed.
|
* @throws \Illuminate\Validation\ValidationException If something failed.
|
||||||
*/
|
*/
|
||||||
private function updateCrmCustomerInfo(Customer $customer, array $data)
|
private function updateCrmCustomerInfo(Customer $customer, array $data): bool
|
||||||
{
|
{
|
||||||
return DB::transaction(function () use ($customer, $data) {
|
return DB::transaction(function () use ($customer, $data) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ use App\Http\Requests\Fo\Customers\CrmQuestionsAnswersRequest;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Game;
|
use App\Models\Game;
|
||||||
use App\Models\StaticPage;
|
use App\Models\StaticPage;
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||||
|
|
@ -25,7 +23,7 @@ class KlubController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function home(): View
|
public function home(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
@ -47,7 +45,7 @@ class KlubController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function questions(): View
|
public function questions(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
@ -68,7 +66,7 @@ class KlubController extends Controller
|
||||||
* @param \App\Http\Requests\Fo\Customers\CrmQuestionsAnswersRequest $request
|
* @param \App\Http\Requests\Fo\Customers\CrmQuestionsAnswersRequest $request
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function questionsSubmit(CrmQuestionsAnswersRequest $request): RedirectResponse
|
public function questionsSubmit(CrmQuestionsAnswersRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ use Illuminate\Support\Str;
|
||||||
use LDC\LDCCRM\Enums\ApiError;
|
use LDC\LDCCRM\Enums\ApiError;
|
||||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||||
use LDC\LDCCRM\Exceptions\CrmException;
|
use LDC\LDCCRM\Exceptions\CrmException;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
||||||
|
|
||||||
class MesBrController extends Controller
|
class MesBrController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +39,7 @@ class MesBrController extends Controller
|
||||||
* @param \App\Http\Requests\Fo\MesBr\PrintCouponsRequest $request
|
* @param \App\Http\Requests\Fo\MesBr\PrintCouponsRequest $request
|
||||||
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|
||||||
*/
|
*/
|
||||||
public function fetchBrPdf(PrintCouponsRequest $request): StreamedResponse
|
public function fetchBrPdf(PrintCouponsRequest $request): \Symfony\Component\HttpFoundation\StreamedResponse
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Customer $customer */
|
/** @var \App\Models\Customer $customer */
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
@ -89,7 +88,6 @@ class MesBrController extends Controller
|
||||||
$mesBr = app('mesBrAPI');
|
$mesBr = app('mesBrAPI');
|
||||||
|
|
||||||
// * MaJ Customer
|
// * MaJ Customer
|
||||||
/** @var integer */
|
|
||||||
retry(3, function () use ($mesBr, $crmUser) {
|
retry(3, function () use ($mesBr, $crmUser) {
|
||||||
/**
|
/**
|
||||||
* Parce que MesBr n'est pas fiable il faut retenter pour avoir
|
* Parce que MesBr n'est pas fiable il faut retenter pour avoir
|
||||||
|
|
@ -263,10 +261,10 @@ class MesBrController extends Controller
|
||||||
* Fetch Crm Customer
|
* Fetch Crm Customer
|
||||||
*
|
*
|
||||||
* @param \App\Models\Customer $customer
|
* @param \App\Models\Customer $customer
|
||||||
* @return \LDC\LDCCRM\Models\Customer
|
* @return \LDC\LDCCRM\Models\Customer|null
|
||||||
* @throws \Illuminate\Http\Exceptions\HttpResponseException In case of failure or customer not activated.
|
* @throws \Illuminate\Http\Exceptions\HttpResponseException In case of failure or customer not activated.
|
||||||
*/
|
*/
|
||||||
private function fetchCrmCustomer(Customer $customer): \LDC\LDCCRM\Models\Customer
|
private function fetchCrmCustomer(Customer $customer): \LDC\LDCCRM\Models\Customer|null
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$crmUser = $customer->api_data;
|
$crmUser = $customer->api_data;
|
||||||
|
|
@ -291,15 +289,16 @@ class MesBrController extends Controller
|
||||||
report($e);
|
report($e);
|
||||||
Log::error('Unhandled response ' . $e->getApiError()->label);
|
Log::error('Unhandled response ' . $e->getApiError()->label);
|
||||||
// * Retenter ?
|
// * Retenter ?
|
||||||
back()->with('error', trans('Une erreur est survenue, veuillez réssayer.'))->throwResponse();
|
redirect()->back()->with('error', trans('Une erreur est survenue, veuillez réssayer.'))->throwResponse();
|
||||||
} catch (HttpResponseException $e) {
|
} catch (HttpResponseException $e) {
|
||||||
// * continue this
|
// * continue this
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch (CrmException | \Exception $e) {
|
} catch (CrmException | \Exception $e) {
|
||||||
report($e);
|
report($e);
|
||||||
// * Retenter ?
|
// * Retenter ?
|
||||||
back()->with('error', trans('Une erreur est survenue, veuillez réssayer.'))->throwResponse();
|
redirect()->back()->with('error', trans('Une erreur est survenue, veuillez réssayer.'))->throwResponse();
|
||||||
} //end try
|
} //end try
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * STATIC Fetch BR
|
// * STATIC Fetch BR
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use App\Models\StaticPage;
|
||||||
class StaticPageController extends Controller
|
class StaticPageController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Legal show
|
* Legal show.
|
||||||
*
|
*
|
||||||
* @param \App\Models\StaticPage $legalPage
|
* @param \App\Models\StaticPage $legalPage
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
|
@ -24,7 +24,7 @@ class StaticPageController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Policies show
|
* Policies show.
|
||||||
*
|
*
|
||||||
* @param \App\Models\StaticPage $policiesPage
|
* @param \App\Models\StaticPage $policiesPage
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
|
@ -36,7 +36,7 @@ class StaticPageController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HistoricalMilestone show
|
* HistoricalMilestone show.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ class Authenticate extends Middleware
|
||||||
}
|
}
|
||||||
return route('fo.login');
|
return route('fo.login');
|
||||||
}
|
}
|
||||||
|
abort(401);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ namespace App\Http\Middleware;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use LDC\LDCCRM\Models\Question;
|
use LDC\LDCCRM\Models\Question;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
class CrmMiddlewareQuestions
|
class CrmMiddlewareQuestions
|
||||||
{
|
{
|
||||||
|
|
@ -17,12 +16,12 @@ class CrmMiddlewareQuestions
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, \Closure $next): Response
|
public function handle(Request $request, \Closure $next): \Symfony\Component\HttpFoundation\Response
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
/** @var \App\Models\Customer|null $user */
|
|
||||||
if (
|
if (
|
||||||
\auth('frontend')->check() and
|
\auth('frontend')->check() and
|
||||||
|
/** @var \App\Models\Customer|null $user */
|
||||||
$user = \auth('frontend')->user() and
|
$user = \auth('frontend')->user() and
|
||||||
$user->last_connection !== null
|
$user->last_connection !== null
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ class StoreGameRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false,
|
'published' => $this->boolean('published'),
|
||||||
'button_status' => $this->button_status ? true : false,
|
'button_status' => $this->boolean('button_status'),
|
||||||
'button_new_tab' => $this->button_status ? true : false,
|
'button_new_tab' => $this->boolean('button_status'),
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture');
|
$this->mergePicture('picture');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ class StoreHistoricalMilestoneRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false,
|
'published' => $this->boolean('published'),
|
||||||
'button_status' => $this->button_status ? true : false,
|
'button_status' => $this->boolean('button_status'),
|
||||||
'button_new_tab' => $this->button_new_tab ? true : false
|
'button_new_tab' => $this->boolean('button_new_tab'),
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture1');
|
$this->mergePicture('picture1');
|
||||||
$this->mergePicture('picture2');
|
$this->mergePicture('picture2');
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class StoreLocalCommitmentRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false
|
'published' => $this->boolean('published')
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture1');
|
$this->mergePicture('picture1');
|
||||||
$this->mergePicture('picture2');
|
$this->mergePicture('picture2');
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class StoreNewsRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false
|
'published' => $this->boolean('published')
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture');
|
$this->mergePicture('picture');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class StorePictoRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false
|
'published' => $this->boolean('published')
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture');
|
$this->mergePicture('picture');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class StoreProductRequest extends FormRequest
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->published ? true : false
|
'published' => $this->boolean('published')
|
||||||
]);
|
]);
|
||||||
$this->mergePicture('picture');
|
$this->mergePicture('picture');
|
||||||
$this->mergePicture('picture_thumbnail');
|
$this->mergePicture('picture_thumbnail');
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class UpdateStaticPageRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return Gate::check('update', $this->route('static_page'));
|
return Gate::check('update', $this->route('static_page'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class UpdateChangeOrderRequest extends FormRequest
|
||||||
protected function prepareForValidation(): void
|
protected function prepareForValidation(): void
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'direction' => $this->string('direction') === 'up' ? true : false
|
'direction' => $this->route('direction') === 'up' ? true : false
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
||||||
$rules = array_merge($rules, [
|
$rules = array_merge($rules, [
|
||||||
"data.$iptName.value" => [
|
"data.$iptName.value" => [
|
||||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
function (string $attribute, $value, callable $fail) use ($sizes) {
|
||||||
return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
$this->compileValidate(
|
$this->compileValidate(
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class StoreUserRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return Gate::check('create', User::class);
|
return Gate::check('create', User::class);
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ class StoreUserRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation(): void
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->boolean('published')
|
'published' => $this->boolean('published')
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class UpdateUserRequest extends StoreUserRequest
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return Gate::check('update', $this->route('user'));
|
return Gate::check('update', $this->route('user'));
|
||||||
}
|
}
|
||||||
|
|
@ -23,14 +23,14 @@ class UpdateUserRequest extends StoreUserRequest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation(): void
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'published' => $this->boolean('published'),
|
'published' => $this->boolean('published'),
|
||||||
'password' => $this->input('password') ??
|
'password' => $this->input('password') ??
|
||||||
$this->route('user')->password,
|
\optional($this->route('user'))->password,
|
||||||
'password_confirmation' => $this->input('password_confirmation') ??
|
'password_confirmation' => $this->input('password_confirmation') ??
|
||||||
$this->route('user')->password
|
\optional($this->route('user'))->password
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ class UpdateUserRequest extends StoreUserRequest
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'email:rfc,strict,dns,spoof,filter',
|
'email:rfc,strict,dns,spoof,filter',
|
||||||
Rule::unique('users', 'email')->ignore($this->route('user')->getRouteKey())
|
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
|
||||||
],
|
],
|
||||||
'password' => [
|
'password' => [
|
||||||
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
class ContactFormRequest extends FormRequest
|
class ContactFormRequest extends FormRequest
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the data for validation.
|
* Prepare the data for validation.
|
||||||
*
|
*
|
||||||
|
|
@ -34,22 +44,12 @@ class ContactFormRequest extends FormRequest
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the user is authorized to make this request.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules(): array
|
||||||
{
|
{
|
||||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||||
return [
|
return [
|
||||||
|
|
@ -94,7 +94,7 @@ class ContactFormRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function attributes()
|
public function attributes(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'subject' => trans('validation.attributes.subject'),
|
'subject' => trans('validation.attributes.subject'),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class CreateAccountRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return Auth::guard('frontend')->check();
|
return Auth::guard('frontend')->check();
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ class CreateAccountRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function prepareForValidation()
|
public function prepareForValidation(): void
|
||||||
{
|
{
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'phone' => $this->input('phone'),
|
'phone' => $this->input('phone'),
|
||||||
|
|
@ -41,7 +41,7 @@ class CreateAccountRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'lastname' => 'required|string|max:255',
|
'lastname' => 'required|string|max:255',
|
||||||
|
|
@ -81,7 +81,7 @@ class CreateAccountRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function attributes()
|
public function attributes(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'lastname' => trans('validation.attributes.first_name'),
|
'lastname' => trans('validation.attributes.first_name'),
|
||||||
|
|
@ -106,7 +106,7 @@ class CreateAccountRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function messages()
|
public function messages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'postal_code' => trans('validation.postal_code', [
|
'postal_code' => trans('validation.postal_code', [
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class CrmQuestionsAnswersRequest extends FormRequest
|
||||||
$customer = auth('frontend')->user();
|
$customer = auth('frontend')->user();
|
||||||
|
|
||||||
/** @var \LDC\LDCCRM\Models\Customer */
|
/** @var \LDC\LDCCRM\Models\Customer */
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$crmCustomer = $customer->apiData;
|
$crmCustomer = $customer->apiData;
|
||||||
|
|
||||||
$this->questions = Customer::cacheCrm(
|
$this->questions = Customer::cacheCrm(
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class UpdateAccountRequest extends CreateAccountRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return array_merge(
|
return array_merge(
|
||||||
\array_intersect_key(
|
\array_intersect_key(
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class UpdatePasswordRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return auth('frontend')->check();
|
return auth('frontend')->check();
|
||||||
}
|
}
|
||||||
|
|
@ -23,9 +23,9 @@ class UpdatePasswordRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules(): array
|
||||||
{
|
{
|
||||||
/** @var \Ldc\LDCCRM\Models\Customer */
|
/** @var \LDC\LDCCRM\Models\Customer */
|
||||||
$crmCustomer = \auth('frontend')->user()->api_data;
|
$crmCustomer = \auth('frontend')->user()->api_data;
|
||||||
return [
|
return [
|
||||||
'old_password' => [
|
'old_password' => [
|
||||||
|
|
@ -44,7 +44,7 @@ class UpdatePasswordRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function attributes()
|
public function attributes(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'old_password' => trans('ancien mot de passe'),
|
'old_password' => trans('ancien mot de passe'),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class GamesStatusUpdate
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): void
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||||
$gamesListToUnPublish = Game::query()
|
$gamesListToUnPublish = Game::query()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class NewsStatusUpdate
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): void
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||||
$newsListToPublish = News::query()
|
$newsListToPublish = News::query()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class CollectionHelper
|
||||||
* @param integer $pageSize
|
* @param integer $pageSize
|
||||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator
|
public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$page = Paginator::resolveCurrentPage('page');
|
$page = Paginator::resolveCurrentPage('page');
|
||||||
|
|
||||||
|
|
@ -31,8 +31,11 @@ class CollectionHelper
|
||||||
* @param integer $page
|
* @param integer $page
|
||||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator
|
public static function paginateManually(
|
||||||
{
|
Collection $results,
|
||||||
|
int $pageSize,
|
||||||
|
int $page = 1
|
||||||
|
): \Illuminate\Pagination\LengthAwarePaginator {
|
||||||
$total = $results->count();
|
$total = $results->count();
|
||||||
|
|
||||||
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
|
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
|
||||||
|
|
@ -51,8 +54,13 @@ class CollectionHelper
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
|
protected static function paginator(
|
||||||
{
|
Collection $items,
|
||||||
|
int $total,
|
||||||
|
int $perPage,
|
||||||
|
int $currentPage,
|
||||||
|
array $options
|
||||||
|
): \Illuminate\Pagination\LengthAwarePaginator {
|
||||||
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
|
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ class ExceptionsHelper
|
||||||
$traceStr .= self::handleArgs($stack);
|
$traceStr .= self::handleArgs($stack);
|
||||||
}
|
}
|
||||||
$traceStr .= ")\n";
|
$traceStr .= ")\n";
|
||||||
} elseif (isset($stack['function'])) {
|
} else {
|
||||||
$traceStr .= "{$stack['function']}(";
|
$traceStr .= "{$stack['function']}(";
|
||||||
if (isset($stack['args'])) {
|
if (isset($stack['args'])) {
|
||||||
$traceStr .= self::handleArgs($stack);
|
$traceStr .= self::handleArgs($stack);
|
||||||
|
|
|
||||||
|
|
@ -322,8 +322,7 @@ class FileStorageHelper
|
||||||
$folderPath = self::getStoragePath(
|
$folderPath = self::getStoragePath(
|
||||||
$private ? 'app/private/modelfiles' : 'app/public/modelfiles',
|
$private ? 'app/private/modelfiles' : 'app/public/modelfiles',
|
||||||
$tableName,
|
$tableName,
|
||||||
$filename,
|
$filename
|
||||||
$private
|
|
||||||
);
|
);
|
||||||
$filename = self::getFileUniqueName($folderPath, $filename);
|
$filename = self::getFileUniqueName($folderPath, $filename);
|
||||||
return "{$folderPath}/{$filename}";
|
return "{$folderPath}/{$filename}";
|
||||||
|
|
@ -418,7 +417,7 @@ class FileStorageHelper
|
||||||
$filename = Str::of($filename)->ltrim('.-');
|
$filename = Str::of($filename)->ltrim('.-');
|
||||||
// * Optional beautification
|
// * Optional beautification
|
||||||
if ($beautify) {
|
if ($beautify) {
|
||||||
$filename = static::beautifyFilename($filename);
|
$filename = self::beautifyFilename($filename);
|
||||||
}
|
}
|
||||||
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|
|
||||||
|
|
@ -175,11 +175,10 @@ class ToolboxHelper
|
||||||
$url = $match;
|
$url = $match;
|
||||||
try {
|
try {
|
||||||
$request = Request::create($url);
|
$request = Request::create($url);
|
||||||
// If a route is match then it do not throws exception.
|
// Assert route matches existing routes.
|
||||||
if (
|
$routes->match($request);
|
||||||
\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST) &&
|
// ? Is url internal ?
|
||||||
$routes->match($request)
|
if (\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST)) {
|
||||||
) {
|
|
||||||
// Removes the matched url.
|
// Removes the matched url.
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
$field => trans(
|
$field => trans(
|
||||||
|
|
@ -205,14 +204,14 @@ class ToolboxHelper
|
||||||
* @param array|string $replace
|
* @param array|string $replace
|
||||||
* @param array|string $subject
|
* @param array|string $subject
|
||||||
* @param integer $count
|
* @param integer $count
|
||||||
* @return array|string
|
* @return array|string|false
|
||||||
*/
|
*/
|
||||||
public static function mbReplace(
|
public static function mbReplace(
|
||||||
array|string $search,
|
array|string $search,
|
||||||
array|string $replace,
|
array|string $replace,
|
||||||
array|string $subject,
|
array|string $subject,
|
||||||
int &$count = 0
|
int &$count = 0
|
||||||
): array|string {
|
): array|string|false {
|
||||||
if (!is_array($search) && is_array($replace)) {
|
if (!is_array($search) && is_array($replace)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -288,10 +287,17 @@ class ToolboxHelper
|
||||||
*/
|
*/
|
||||||
public static function getOriginal(Model $model, string $attribute): mixed
|
public static function getOriginal(Model $model, string $attribute): mixed
|
||||||
{
|
{
|
||||||
if (\in_array('Spatie\Translatable\HasTranslations', \class_uses_recursive($model))) {
|
if (
|
||||||
|
\in_array('Spatie\Translatable\HasTranslations', \class_uses_recursive($model)) and
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
|
$model->isTranslatableAttribute($attribute)
|
||||||
|
) {
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
return $model->getTranslation(
|
return $model->getTranslation(
|
||||||
$attribute,
|
$attribute,
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$model->getLocale(),
|
$model->getLocale(),
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$model->useFallbackLocale()
|
$model->useFallbackLocale()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -361,14 +367,16 @@ class ToolboxHelper
|
||||||
/**
|
/**
|
||||||
* Convert deeply an object to array
|
* Convert deeply an object to array
|
||||||
*
|
*
|
||||||
* @param array|object $input
|
* @param mixed $input
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \RuntimeException If $input var is a scalar value.
|
* @throws \RuntimeException If $input var is a scalar value.
|
||||||
*/
|
*/
|
||||||
public static function objectToArray($input): array
|
public static function objectToArray(mixed $input): array
|
||||||
{
|
{
|
||||||
// Only process if it's an object or array being passed to the function.
|
// Only process if it's an object or array being passed to the function.
|
||||||
if (is_object($input) or is_array($input)) {
|
if (!(is_object($input) or is_array($input))) {
|
||||||
|
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
||||||
|
}
|
||||||
$ret = (array)$input;
|
$ret = (array)$input;
|
||||||
foreach ($ret as &$item) {
|
foreach ($ret as &$item) {
|
||||||
// Recursively process EACH element only if not scalar.
|
// Recursively process EACH element only if not scalar.
|
||||||
|
|
@ -376,22 +384,21 @@ class ToolboxHelper
|
||||||
self::objectToArray($item) : $item;
|
self::objectToArray($item) : $item;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert deeply an array to object
|
* Convert deeply an array to object
|
||||||
*
|
*
|
||||||
* @param array|object $input
|
* @param mixed $input
|
||||||
* @return object
|
* @return object
|
||||||
* @throws \RuntimeException If $input var is a scalar value.
|
* @throws \RuntimeException If $input var is a scalar value.
|
||||||
*/
|
*/
|
||||||
public static function arrayToObject($input): object
|
public static function arrayToObject(mixed $input): object
|
||||||
{
|
{
|
||||||
// Only process if it's an object or array being passed to the function.
|
// Only process if it's an object or array being passed to the function.
|
||||||
if (is_object($input) or is_array($input)) {
|
if (!(is_object($input) or is_array($input))) {
|
||||||
|
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
||||||
|
}
|
||||||
$ret = (object)$input;
|
$ret = (object)$input;
|
||||||
foreach ($ret as &$item) {
|
foreach ($ret as &$item) {
|
||||||
// Recursively process EACH element only if not scalar.
|
// Recursively process EACH element only if not scalar.
|
||||||
|
|
@ -399,9 +406,6 @@ class ToolboxHelper
|
||||||
self::arrayToObject($item) : $item;
|
self::arrayToObject($item) : $item;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -409,11 +413,11 @@ class ToolboxHelper
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param string|null $value
|
* @param string|null $value
|
||||||
* @param callback $fail
|
* @param callable $fail
|
||||||
* @param object $sizes
|
* @param object $sizes
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes)
|
public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes): void
|
||||||
{
|
{
|
||||||
if (!($useStorage = Storage::exists($value)) and !File::exists($value)) {
|
if (!($useStorage = Storage::exists($value)) and !File::exists($value)) {
|
||||||
$fail(trans(':attribute n\'existe pas dans le système de fichier', [
|
$fail(trans(':attribute n\'existe pas dans le système de fichier', [
|
||||||
|
|
@ -421,7 +425,6 @@ class ToolboxHelper
|
||||||
]));
|
]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/** @var string */
|
|
||||||
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
|
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
|
||||||
if (
|
if (
|
||||||
!\in_array(self::getUploadedFileMimeType($value, $useStorage), [
|
!\in_array(self::getUploadedFileMimeType($value, $useStorage), [
|
||||||
|
|
@ -432,7 +435,7 @@ class ToolboxHelper
|
||||||
'attribute' => $attribute
|
'attribute' => $attribute
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
if (!($dimensions = \getimagesize($fileFullPath)) or !isset($dimensions[0]) or !isset($dimensions[1])) {
|
if (!($dimensions = \getimagesize($fileFullPath))) {
|
||||||
$fail(trans(':attribute impossible de valider les dimensions', [
|
$fail(trans(':attribute impossible de valider les dimensions', [
|
||||||
'attribute' => $attribute
|
'attribute' => $attribute
|
||||||
]));
|
]));
|
||||||
|
|
@ -441,19 +444,19 @@ class ToolboxHelper
|
||||||
$height = intval($dimensions[1]);
|
$height = intval($dimensions[1]);
|
||||||
|
|
||||||
$xMessage = trans(
|
$xMessage = trans(
|
||||||
":attribute la largeur doit être comprise entre {$sizes->minWith}px et {$sizes->maxWith}px"
|
":attribute la largeur doit être comprise entre {$sizes->minWidth}px et {$sizes->maxWidth}px"
|
||||||
);
|
);
|
||||||
if ($sizes->minWith === $sizes->maxWith) {
|
if ($sizes->minWidth === $sizes->maxWidth) {
|
||||||
$xMessage = trans(":attribute la largeur doit être de {$sizes->minWith}px");
|
$xMessage = trans(":attribute la largeur doit être de {$sizes->minWidth}px");
|
||||||
}
|
}
|
||||||
$yMessage = trans(
|
$yMessage = trans(
|
||||||
":attribute la hauteur doit être comprise entre {$sizes->minWith}px et {$sizes->maxWith}px"
|
":attribute la hauteur doit être comprise entre {$sizes->minWidth}px et {$sizes->maxWidth}px"
|
||||||
);
|
);
|
||||||
if ($sizes->minHeight === $sizes->maxHeight) {
|
if ($sizes->minHeight === $sizes->maxHeight) {
|
||||||
$yMessage = trans(":attribute la hauteur doit être de {$sizes->minHeight}px");
|
$yMessage = trans(":attribute la hauteur doit être de {$sizes->minHeight}px");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($width < $sizes->minWith) or ($width > $sizes->maxWith)) {
|
if (($width < $sizes->minWidth) or ($width > $sizes->maxWidth)) {
|
||||||
$fail($xMessage);
|
$fail($xMessage);
|
||||||
}
|
}
|
||||||
if (($height < $sizes->minHeight) or ($height > $sizes->maxHeight)) {
|
if (($height < $sizes->minHeight) or ($height > $sizes->maxHeight)) {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class SendContactMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function __construct(\stdClass $data)
|
public function __construct(\stdClass $data)
|
||||||
{
|
{
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$this->data = clone $data;
|
$this->data = clone $data;
|
||||||
$this->sanitizeStringInputs();
|
$this->sanitizeStringInputs();
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +50,7 @@ class SendContactMail extends Mailable
|
||||||
*/
|
*/
|
||||||
private function sanitizeStringInputs(): void
|
private function sanitizeStringInputs(): void
|
||||||
{
|
{
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$this->data = (object)Arr::map((array)$this->data, function ($el) {
|
$this->data = (object)Arr::map((array)$this->data, function ($el) {
|
||||||
if (is_string($el)) {
|
if (is_string($el)) {
|
||||||
$el = \htmlspecialchars(\strip_tags(Blade::render(
|
$el = \htmlspecialchars(\strip_tags(Blade::render(
|
||||||
|
|
@ -71,8 +73,13 @@ class SendContactMail extends Mailable
|
||||||
public function envelope(): \Illuminate\Mail\Mailables\Envelope
|
public function envelope(): \Illuminate\Mail\Mailables\Envelope
|
||||||
{
|
{
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
subject: sprintf('%s - %s', ObjectEnum::make($this->data->type)->label() ??
|
subject: sprintf(
|
||||||
__('Nouveau message'), config('app.name')),
|
'%s - %s',
|
||||||
|
(isset($this->data->type)) ?
|
||||||
|
ObjectEnum::make($this->data->type)->label() :
|
||||||
|
__('Nouveau message'),
|
||||||
|
config('app.name')
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\ActivityLogs\ActivityLogsEventEnum;
|
use App\Enums\ActivityLogs\ActivityLogsEventEnum;
|
||||||
use Carbon\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
@ -12,9 +12,9 @@ use Illuminate\Support\Facades\Schema;
|
||||||
/**
|
/**
|
||||||
* @property string $model Target model.
|
* @property string $model Target model.
|
||||||
* @property string $model_id Id of the target model.
|
* @property string $model_id Id of the target model.
|
||||||
* @property string $event Event of this activity (ActivityLogsEventEnum).
|
* @property \App\Enums\ActivityLogs\ActivityLogsEventEnum $event Event of this activity (ActivityLogsEventEnum).
|
||||||
* @property string $data Changes.
|
* @property array $data Changes.
|
||||||
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
* @property \Illuminate\Support\Carbon $created_at Created date.
|
||||||
*
|
*
|
||||||
* @property-read \App\Models\User $user User BelongsTo relation.
|
* @property-read \App\Models\User $user User BelongsTo relation.
|
||||||
*/
|
*/
|
||||||
|
|
@ -81,7 +81,7 @@ class ActivityLog extends Model
|
||||||
$activity->model_class = \get_class($model);
|
$activity->model_class = \get_class($model);
|
||||||
$activity->model_id = $model->getKey();
|
$activity->model_id = $model->getKey();
|
||||||
$activity->event = $eventEnum;
|
$activity->event = $eventEnum;
|
||||||
$activity->data = static::getChangedColumns($activity, $model, $eventEnum);
|
$activity->data = self::getChangedColumns($activity, $model, $eventEnum);
|
||||||
$activity->created_at = Carbon::now();
|
$activity->created_at = Carbon::now();
|
||||||
$activity->saveOrFail();
|
$activity->saveOrFail();
|
||||||
}
|
}
|
||||||
|
|
@ -89,13 +89,17 @@ class ActivityLog extends Model
|
||||||
/**
|
/**
|
||||||
* Get old, new columns that has changed.
|
* Get old, new columns that has changed.
|
||||||
*
|
*
|
||||||
* @param \self $activity
|
* @param \App\Models\ActivityLog $activity
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
* @param \App\Enums\ActivityLogs\ActivityLogsEventEnum $eventEnum
|
* @param \App\Enums\ActivityLogs\ActivityLogsEventEnum $eventEnum
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function getChangedColumns(self $activity, Model $model, ActivityLogsEventEnum $eventEnum): array|null
|
public static function getChangedColumns(
|
||||||
{
|
ActivityLog $activity,
|
||||||
|
Model $model,
|
||||||
|
ActivityLogsEventEnum $eventEnum
|
||||||
|
): array|null {
|
||||||
|
$targetModelTypes = [];
|
||||||
$modelClassName = $activity->model_class;
|
$modelClassName = $activity->model_class;
|
||||||
/** Get type of each fields of the target model */
|
/** Get type of each fields of the target model */
|
||||||
$targetModel = $activity->model_class::where(
|
$targetModel = $activity->model_class::where(
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use LDC\LDCCRM\Models\Customer as CrmCustomer;
|
||||||
* @property string $email Email.
|
* @property string $email Email.
|
||||||
* @property string $hashcode Hashcode.
|
* @property string $hashcode Hashcode.
|
||||||
* @property string $remember_token Remember token.
|
* @property string $remember_token Remember token.
|
||||||
* @property \LDC\LDCCRM\Models\Customer api_data
|
* @property \LDC\LDCCRM\Models\Customer $api_data
|
||||||
* @property \Carbon\Carbon|null $email_verified_at
|
* @property \Carbon\Carbon|null $email_verified_at
|
||||||
* @property \Carbon\Carbon|null $last_connection Date de derniere connexion, (pour les questions oblig CRM).
|
* @property \Carbon\Carbon|null $last_connection Date de derniere connexion, (pour les questions oblig CRM).
|
||||||
* @property-read \Carbon\Carbon $created_at Created date.
|
* @property-read \Carbon\Carbon $created_at Created date.
|
||||||
|
|
@ -68,10 +68,10 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
{
|
{
|
||||||
// * EVENT CLOSURES.
|
// * EVENT CLOSURES.
|
||||||
static::creating(function (self $model) {
|
static::creating(function (self $model) {
|
||||||
static::assertEmailIsUnique($model->id, $model->email);
|
self::assertEmailIsUnique($model->id, $model->email);
|
||||||
});
|
});
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
static::assertEmailIsUnique($model->id, $model->email);
|
self::assertEmailIsUnique($model->id, $model->email);
|
||||||
});
|
});
|
||||||
static::deleted(function (self $model) {
|
static::deleted(function (self $model) {
|
||||||
if ($model->forceDeleting) {
|
if ($model->forceDeleting) {
|
||||||
|
|
@ -99,11 +99,11 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
*
|
*
|
||||||
* ! Les comptes non activés depuis une semaine ou les comptes supprimés depuis une semaine.
|
* ! Les comptes non activés depuis une semaine ou les comptes supprimés depuis une semaine.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Query\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
public function prunable(): Builder
|
public function prunable(): \Illuminate\Database\Eloquent\Builder
|
||||||
{
|
{
|
||||||
return static::query()->where(function (Builder $q) {
|
return self::query()->where(function (Builder $q) {
|
||||||
$q->where('updated_at', '<=', now()->subWeek())
|
$q->where('updated_at', '<=', now()->subWeek())
|
||||||
->whereNull('email_verified_at');
|
->whereNull('email_verified_at');
|
||||||
})->orWhere(function (Builder $q) {
|
})->orWhere(function (Builder $q) {
|
||||||
|
|
@ -173,7 +173,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
return $this->api_data->activate() && parent::markEmailAsVerified();
|
return $this->api_data->activate() && parent::markEmailAsVerified();
|
||||||
} catch (ApiErrorException $e) {
|
} catch (ApiErrorException $e) {
|
||||||
if ($e->getApiError()->equals(ApiError::customerAlreadyActive())) {
|
if ($e->getApiError()->equals(ApiError::customerAlreadyActive())) {
|
||||||
return true && parent::markEmailAsVerified();
|
return parent::markEmailAsVerified();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +216,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
}
|
}
|
||||||
/** @var static|null $loggedCustomer */
|
/** @var static|null $loggedCustomer */
|
||||||
$loggedCustomer = \auth('frontend')->user();
|
$loggedCustomer = \auth('frontend')->user();
|
||||||
$isLogged = \optional($loggedCustomer)->id === $this->id and !\is_null($this->id);
|
$isLogged = \optional($loggedCustomer)->id === $this->id and !isset($this->id);
|
||||||
if ($isLogged) {
|
if ($isLogged) {
|
||||||
\auth('frontend')->logout();
|
\auth('frontend')->logout();
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
public function updateApiData(array $data): bool
|
public function updateApiData(array $data): bool
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
/** @var \LDC\LDCCRM\Models\Customer */
|
/** @var \LDC\LDCCRM\Models\Customer|null $crmCustomer */
|
||||||
$crmCustomer = $this->api_data;
|
$crmCustomer = $this->api_data;
|
||||||
if (!$crmCustomer) {
|
if (!$crmCustomer) {
|
||||||
throw new CrmException('CRM get Customer returned null');
|
throw new CrmException('CRM get Customer returned null');
|
||||||
|
|
@ -302,6 +302,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60)
|
public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
return Cache::remember("customers.{$uuid}.{$part_name}", $ttl, $part);
|
return Cache::remember("customers.{$uuid}.{$part_name}", $ttl, $part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,9 +334,11 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
if ($this->hashcode) {
|
if ($this->hashcode) {
|
||||||
|
/** @var \LDC\LDCCRM\Models\Customer $crmCustomer */
|
||||||
|
$crmCustomer = $this->api_data;
|
||||||
return collect(array_merge(
|
return collect(array_merge(
|
||||||
parent::toArray(),
|
parent::toArray(),
|
||||||
(array)$this->apiData
|
(array)$crmCustomer
|
||||||
))->intersectByKeys([
|
))->intersectByKeys([
|
||||||
'email' => '',
|
'email' => '',
|
||||||
'firstname' => '',
|
'firstname' => '',
|
||||||
|
|
@ -351,6 +354,6 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
||||||
])->toArray();
|
])->toArray();
|
||||||
} else {
|
} else {
|
||||||
return parent::toArray();
|
return parent::toArray();
|
||||||
}
|
} //end if
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class StaticPage extends Model
|
||||||
});
|
});
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
// * ASSERTIONS
|
// * ASSERTIONS
|
||||||
static::assertTitleIsUnique($model->title, $model->id);
|
self::assertTitleIsUnique($model->title, $model->id);
|
||||||
|
|
||||||
// * CHANGES
|
// * CHANGES
|
||||||
$model->slug = Str::slug($model->title);
|
$model->slug = Str::slug($model->title);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ class User extends Authenticatable
|
||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
static::creating(function (self $model) {
|
static::creating(function (self $model) {
|
||||||
static::updatePassword($model);
|
self::updatePassword($model);
|
||||||
// * Prevent user elevation privileges
|
// * Prevent user elevation privileges
|
||||||
throw_if(
|
throw_if(
|
||||||
auth('backend')->user() and auth('backend')->user()->role->value() > $model->role->value(),
|
auth('backend')->user() and auth('backend')->user()->role->value() > $model->role->value(),
|
||||||
|
|
@ -81,7 +81,7 @@ class User extends Authenticatable
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
static::updatePassword($model);
|
self::updatePassword($model);
|
||||||
if (optional(auth('backend')->user())->getKey() === $model->getKey()) {
|
if (optional(auth('backend')->user())->getKey() === $model->getKey()) {
|
||||||
\validator(
|
\validator(
|
||||||
['published' => $model->published],
|
['published' => $model->published],
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class DestroyCustomer extends Notification
|
||||||
* @param object $notifiable
|
* @param object $notifiable
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
*/
|
*/
|
||||||
public function toMail(object $notifiable): MailMessage
|
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||||
{
|
{
|
||||||
/** @var string $firstname */
|
/** @var string $firstname */
|
||||||
$firstname = $notifiable->api_data->firstname;
|
$firstname = $notifiable->api_data->firstname;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class DestroyedCustomer extends Notification
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||||
*/
|
*/
|
||||||
public function toMail(object $notifiable): MailMessage
|
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class ResetPassword extends NotificationsResetPassword
|
||||||
/**
|
/**
|
||||||
* The callback that should be used to create the reset password URL.
|
* The callback that should be used to create the reset password URL.
|
||||||
*
|
*
|
||||||
* @var \Closure|null
|
* @var (\Closure(mixed , string ): string)|null
|
||||||
*/
|
*/
|
||||||
public static $createUrlCallback;
|
public static $createUrlCallback;
|
||||||
|
|
||||||
|
|
@ -44,10 +44,10 @@ class ResetPassword extends NotificationsResetPassword
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
/** @var \App\Models\Customer\Customer $notifiable */
|
/** @var \App\Models\Customer $notifiable */
|
||||||
$resetUrl = $this->resetUrl($notifiable);
|
$resetUrl = $this->resetUrl($notifiable);
|
||||||
/** @var string $firstname */
|
/** @var string $firstname */
|
||||||
$firstname = $notifiable->api_data->firstname;
|
$firstname = $notifiable->api_data->firstname;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class UpdatePassword extends Notification
|
||||||
* @param object $notifiable
|
* @param object $notifiable
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
*/
|
*/
|
||||||
public function toMail(object $notifiable): MailMessage
|
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||||
{
|
{
|
||||||
/** @var string $firstname */
|
/** @var string $firstname */
|
||||||
$firstname = $notifiable->api_data->firstname;
|
$firstname = $notifiable->api_data->firstname;
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ class VerifyEmail extends NotificationsVerifyEmail
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
/** @var \App\Models\Customer\Customer $notifiable */
|
/** @var \App\Models\Customer $notifiable */
|
||||||
$verificationUrl = $this->verificationUrl($notifiable);
|
$verificationUrl = $this->verificationUrl($notifiable);
|
||||||
$firstname = $notifiable->api_data->firstname;
|
$firstname = $notifiable->api_data->firstname;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||||
return $user->role === RoleEnum::conceptor;
|
return $user->role === RoleEnum::conceptor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$this->app->auth->provider('crm', function ($app, array $config) {
|
$this->app->auth->provider('crm', function ($app, array $config) {
|
||||||
return new CrmUserProvider($app['hash'], $config['model']);
|
return new CrmUserProvider($app['hash'], $config['model']);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class TranslationServiceProvider extends ServiceProvider
|
||||||
/**
|
/**
|
||||||
* Gather provided langs checking from files
|
* Gather provided langs checking from files
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\Collection<string, string>
|
* @return \Illuminate\Support\Collection<int, string>
|
||||||
*/
|
*/
|
||||||
private function collectLocalesStrings(): Collection
|
private function collectLocalesStrings(): Collection
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Traits\Controllers;
|
namespace App\Traits\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
|
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
@ -14,33 +14,22 @@ trait ChangesModelOrder
|
||||||
* Change order.
|
* Change order.
|
||||||
*
|
*
|
||||||
* @param \App\Http\Requests\Bo\UpdateChangeOrderRequest $request
|
* @param \App\Http\Requests\Bo\UpdateChangeOrderRequest $request
|
||||||
* @param mixed ...$params
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @throws \RuntimeException Si le nom du parametre de la route ne correspond pas au params utilisé.
|
* @throws \RuntimeException Si le nom du parametre de la route ne correspond pas au model utilisé.
|
||||||
*/
|
*/
|
||||||
public function changeOrder(UpdateChangeOrderRequest $request, mixed ...$params): \Illuminate\Http\RedirectResponse
|
public function changeOrder(UpdateChangeOrderRequest $request, Model $model): \Illuminate\Http\RedirectResponse
|
||||||
{
|
{
|
||||||
$paramNames = collect(request()->route()->parameterNames);
|
$params = collect(request()->route()->parameterNames);
|
||||||
$className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly();
|
$className = Str::ucfirst(Str::lower($params->get($params->count() - 2)));
|
||||||
$className = "\\App\\Models\\{$className}";
|
$className = "\\App\\Models\\$className";
|
||||||
$model = Arr::get($params, $paramNames->count() - 2);
|
|
||||||
|
|
||||||
if (!class_exists($className)) {
|
if (!class_exists($className)) {
|
||||||
throw new \RuntimeException("The {$className} class doesn't exist.");
|
throw new \RuntimeException("The $className class doesn't exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_object($model)) {
|
|
||||||
throw new \RuntimeException("The second last param isn't an object.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_class($model) !== Str::of($className)->replaceStart('\\', '')->value()) {
|
|
||||||
throw new \RuntimeException("The {$className} doesn't match second last binded param.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Model $model */
|
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Model|null */
|
/** @var \Illuminate\Database\Eloquent\Model|null */
|
||||||
$model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first();
|
$model = $className::where($model->getRouteKeyName(), $model->getRouteKey())->first();
|
||||||
|
|
||||||
if (!$model) {
|
if (!$model) {
|
||||||
return back()->with('error', trans('crud.messages.order_not_changed'));
|
return back()->with('error', trans('crud.messages.order_not_changed'));
|
||||||
|
|
@ -48,18 +37,16 @@ trait ChangesModelOrder
|
||||||
|
|
||||||
return DB::transaction(function () use ($request, $className, $model) {
|
return DB::transaction(function () use ($request, $className, $model) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Model|null */
|
/** @var \Illuminate\Database\Eloquent\Model|null */
|
||||||
$tmp = $className::query()->where('order', $request->direction ? '<' : '>', $model->order)
|
$tmp = $className::where('order', $request->direction ? '<' : '>', $model->getOriginal('order'))
|
||||||
->orderBy('order', $request->direction ? 'DESC' : 'ASC')->first();
|
->orderBy('order', $request->direction ? 'DESC' : 'ASC')->first();
|
||||||
|
|
||||||
if (!$tmp) {
|
if (!$tmp) {
|
||||||
return back()->with('error', trans('crud.messages.order_not_changed'));
|
return back()->with('error', trans('crud.messages.order_not_changed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$newOrder = $tmp->order;
|
$newOrder = $tmp->getOriginal('order');
|
||||||
$tmp->order = $model->order;
|
$tmp->update(['order' => $model->getOriginal('order')]);
|
||||||
$model->order = $newOrder;
|
$model->update(['order' => $newOrder]);
|
||||||
$tmp->saveOrFail();
|
|
||||||
$model->saveOrFail();
|
|
||||||
Session::flash('success', trans('crud.messages.order_changed'));
|
Session::flash('success', trans('crud.messages.order_changed'));
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ trait UpdateModelPublished
|
||||||
*/
|
*/
|
||||||
public function changePublished(Model $model)
|
public function changePublished(Model $model)
|
||||||
{
|
{
|
||||||
$model->published = !$model->published;
|
$model->update(['published' => !$model->getOriginal('published')]);
|
||||||
$model->saveOrFail();
|
|
||||||
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
|
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,9 @@ trait BaseEnum
|
||||||
/**
|
/**
|
||||||
* Fetch enum using value.
|
* Fetch enum using value.
|
||||||
*
|
*
|
||||||
* @param \App\Traits\Enums\BaseEnum|integer|string $value
|
* @param self|integer|string $value
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @return \App\Traits\Enums\BaseEnum|null
|
* @return self|null
|
||||||
*/
|
*/
|
||||||
public static function make(self|int|string $value, string $field = 'value'): self|null
|
public static function make(self|int|string $value, string $field = 'value'): self|null
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Cache;
|
||||||
/**
|
/**
|
||||||
* ! Use this only on limited elements, (not on tags, or products, or posts for ex.)
|
* ! Use this only on limited elements, (not on tags, or products, or posts for ex.)
|
||||||
*
|
*
|
||||||
* @property private static array $cacheConditions Eloquent condition to cache elements (to be used in where statement).
|
* @property array<string,string|integer|float|boolean> $cacheConditions
|
||||||
|
* Eloquent condition to cache elements (to be used in where statement).
|
||||||
*/
|
*/
|
||||||
trait IsCachedAsCollection
|
trait IsCachedAsCollection
|
||||||
{
|
{
|
||||||
|
|
@ -18,9 +19,9 @@ trait IsCachedAsCollection
|
||||||
* Get all available instances from cache.
|
* Get all available instances from cache.
|
||||||
* If cache was reset, it will fetch them from DB.
|
* If cache was reset, it will fetch them from DB.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
* @return \Illuminate\Support\Collection<(int|string)>
|
||||||
*/
|
*/
|
||||||
public static function getCached(): Collection
|
public static function getCached(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
if (!Cache::has(static::getCacheKeyName())) {
|
if (!Cache::has(static::getCacheKeyName())) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -34,7 +35,7 @@ trait IsCachedAsCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove cached elements
|
* Remove cached elements.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,7 +53,8 @@ trait IsCachedAsCollection
|
||||||
{
|
{
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
if (property_exists(get_called_class(), 'cacheConditions')) {
|
if (property_exists(get_called_class(), 'cacheConditions')) {
|
||||||
$conditions = collect(static::${'cacheConditions'})->all();
|
// @phpstan-ignore-next-line
|
||||||
|
$conditions = collect(self::${'cacheConditions'})->all();
|
||||||
}
|
}
|
||||||
Cache::put(static::getCacheKeyName(), static::queryCached(static::query())
|
Cache::put(static::getCacheKeyName(), static::queryCached(static::query())
|
||||||
->where($conditions)->get()
|
->where($conditions)->get()
|
||||||
|
|
@ -60,29 +62,29 @@ trait IsCachedAsCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change query for cached elements
|
* Change query for cached elements.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
protected static function queryCached(Builder $query): Builder
|
protected static function queryCached(Builder $query): \Illuminate\Database\Eloquent\Builder
|
||||||
{
|
{
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change query for cached elements
|
* Change query for cached elements.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Support\Collection $results
|
* @param \Illuminate\Support\Collection $results
|
||||||
* @return \Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection
|
||||||
*/
|
*/
|
||||||
protected static function filterQuery(Collection $results): Collection
|
protected static function filterQuery(Collection $results): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class basename
|
* Get the class basename.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
@ -92,7 +94,7 @@ trait IsCachedAsCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class basename
|
* Get the class basename.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ trait HasPicture
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $minWith = 400;
|
private $minWidth = 400;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum width
|
* Maximum width
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $maxWith = 1800;
|
private $maxWidth = 1800;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimum height
|
* Minimum height
|
||||||
|
|
@ -41,32 +41,41 @@ trait HasPicture
|
||||||
* Image rules
|
* Image rules
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param integer|null $minWith
|
* @param integer|null $minWidth
|
||||||
* @param integer|null $minHeight
|
* @param integer|null $minHeight
|
||||||
* @param integer|null $maxWith
|
* @param integer|null $maxWidth
|
||||||
* @param integer|null $maxHeight
|
* @param integer|null $maxHeight
|
||||||
* @param boolean $nullable
|
* @param boolean $nullable
|
||||||
|
* @param integer|null $size
|
||||||
|
* @param string|null $requiredWith
|
||||||
|
* @param string|null $requiredWithout
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function pictureRules(
|
public function pictureRules(
|
||||||
string $name = 'picture',
|
string $name = 'picture',
|
||||||
?int $minWith = null,
|
?int $minWidth = null,
|
||||||
?int $minHeight = null,
|
?int $minHeight = null,
|
||||||
?int $maxWith = null,
|
?int $maxWidth = null,
|
||||||
?int $maxHeight = null,
|
?int $maxHeight = null,
|
||||||
bool $nullable = false
|
bool $nullable = false,
|
||||||
|
?int $size = null,
|
||||||
|
?string $requiredWith = null,
|
||||||
|
?string $requiredWithout = null,
|
||||||
): array {
|
): array {
|
||||||
$sizes = (object)[
|
$dimensions = (object)[
|
||||||
'minWith' => $minWith ?? $this->minWith,
|
'minWidth' => $minWidth ?? $this->minWidth,
|
||||||
'minHeight' => $minHeight ?? $this->minHeight,
|
'minHeight' => $minHeight ?? $this->minHeight,
|
||||||
'maxWith' => $maxWith ?? $this->maxWith,
|
'maxWidth' => $maxWidth ?? $this->maxWidth,
|
||||||
'maxHeight' => $maxHeight ?? $this->maxHeight
|
'maxHeight' => $maxHeight ?? $this->maxHeight
|
||||||
];
|
];
|
||||||
return [
|
return [
|
||||||
$name => [
|
$name => [
|
||||||
!$nullable ? 'required' : 'nullable',
|
!$nullable ? 'required' : 'nullable',
|
||||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
(strlen($requiredWith)) ? 'required_with:' . $requiredWith : '',
|
||||||
return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
(strlen($requiredWithout)) ? 'required_without:' . $requiredWithout : '',
|
||||||
|
($size) ? 'max:' . $size : '',
|
||||||
|
function (string $attribute, $value, callable $fail) use ($dimensions) {
|
||||||
|
ToolboxHelper::validatePicture($attribute, $value, $fail, $dimensions);
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
@ -76,23 +85,23 @@ trait HasPicture
|
||||||
* Images rules
|
* Images rules
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param integer|null $minWith
|
* @param integer|null $minWidth
|
||||||
* @param integer|null $minHeight
|
* @param integer|null $minHeight
|
||||||
* @param integer|null $maxWith
|
* @param integer|null $maxWidth
|
||||||
* @param integer|null $maxHeight
|
* @param integer|null $maxHeight
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function picturesRules(
|
public function picturesRules(
|
||||||
string $name = 'pictures',
|
string $name = 'pictures',
|
||||||
?int $minWith = null,
|
?int $minWidth = null,
|
||||||
?int $minHeight = null,
|
?int $minHeight = null,
|
||||||
?int $maxWith = null,
|
?int $maxWidth = null,
|
||||||
?int $maxHeight = null
|
?int $maxHeight = null
|
||||||
): array {
|
): array {
|
||||||
$sizes = (object)[
|
$sizes = (object)[
|
||||||
'minWith' => $minWith ?? $this->minWith,
|
'minWidth' => $minWidth ?? $this->minWidth,
|
||||||
'minHeight' => $minHeight ?? $this->minHeight,
|
'minHeight' => $minHeight ?? $this->minHeight,
|
||||||
'maxWith' => $maxWith ?? $this->maxWith,
|
'maxWidth' => $maxWidth ?? $this->maxWidth,
|
||||||
'maxHeight' => $maxHeight ?? $this->maxHeight
|
'maxHeight' => $maxHeight ?? $this->maxHeight
|
||||||
];
|
];
|
||||||
return [
|
return [
|
||||||
|
|
@ -101,7 +110,7 @@ trait HasPicture
|
||||||
"{$name}Validate.*" => [
|
"{$name}Validate.*" => [
|
||||||
'required',
|
'required',
|
||||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
function (string $attribute, $value, callable $fail) use ($sizes) {
|
||||||
return $this->validatePicture($attribute, $value, $fail, $sizes);
|
ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
"larastan/larastan": "^2.8",
|
||||||
"laravel-lang/common": "^4.0",
|
"laravel-lang/common": "^4.0",
|
||||||
"laravel/pint": "^1.0",
|
"laravel/pint": "^1.0",
|
||||||
"laravel/sail": "^1.18",
|
"laravel/sail": "^1.18",
|
||||||
|
|
|
||||||
253
composer.lock
generated
253
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b72fd73d510285ac10b0b17fe78928c9",
|
"content-hash": "c5101a95c61f5cc18999a10e3cfa6190",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "axlon/laravel-postal-code-validation",
|
"name": "axlon/laravel-postal-code-validation",
|
||||||
|
|
@ -10024,6 +10024,107 @@
|
||||||
},
|
},
|
||||||
"time": "2020-07-09T08:09:16+00:00"
|
"time": "2020-07-09T08:09:16+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "larastan/larastan",
|
||||||
|
"version": "v2.8.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/larastan/larastan.git",
|
||||||
|
"reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/larastan/larastan/zipball/b7cc6a29c457a7d4f3de90466392ae9ad3e17022",
|
||||||
|
"reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"illuminate/console": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/container": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/database": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/http": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"illuminate/support": "^9.52.16 || ^10.28.0 || ^11.0",
|
||||||
|
"php": "^8.0.2",
|
||||||
|
"phpmyadmin/sql-parser": "^5.8.2",
|
||||||
|
"phpstan/phpstan": "^1.10.50"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"nikic/php-parser": "^4.17.1",
|
||||||
|
"orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.0",
|
||||||
|
"orchestra/testbench": "^7.33.0 || ^8.13.0 || ^9.0.0",
|
||||||
|
"phpunit/phpunit": "^9.6.13 || ^10.5"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench"
|
||||||
|
},
|
||||||
|
"type": "phpstan-extension",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.0-dev"
|
||||||
|
},
|
||||||
|
"phpstan": {
|
||||||
|
"includes": [
|
||||||
|
"extension.neon"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Larastan\\Larastan\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Can Vural",
|
||||||
|
"email": "can9119@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nuno Maduro",
|
||||||
|
"email": "enunomaduro@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"PHPStan",
|
||||||
|
"code analyse",
|
||||||
|
"code analysis",
|
||||||
|
"larastan",
|
||||||
|
"laravel",
|
||||||
|
"package",
|
||||||
|
"php",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/larastan/larastan/issues",
|
||||||
|
"source": "https://github.com/larastan/larastan/tree/v2.8.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/paypalme/enunomaduro",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/canvural",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nunomaduro",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/nunomaduro",
|
||||||
|
"type": "patreon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-01-08T09:11:17+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel-lang/attributes",
|
"name": "laravel-lang/attributes",
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
|
|
@ -10988,6 +11089,94 @@
|
||||||
},
|
},
|
||||||
"time": "2022-02-21T01:04:05+00:00"
|
"time": "2022-02-21T01:04:05+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpmyadmin/sql-parser",
|
||||||
|
"version": "5.9.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpmyadmin/sql-parser.git",
|
||||||
|
"reference": "011fa18a4e55591fac6545a821921dd1d61c6984"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/011fa18a4e55591fac6545a821921dd1d61c6984",
|
||||||
|
"reference": "011fa18a4e55591fac6545a821921dd1d61c6984",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3",
|
||||||
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpmyadmin/motranslator": "<3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpbench/phpbench": "^1.1",
|
||||||
|
"phpmyadmin/coding-standard": "^3.0",
|
||||||
|
"phpmyadmin/motranslator": "^4.0 || ^5.0",
|
||||||
|
"phpstan/extension-installer": "^1.1",
|
||||||
|
"phpstan/phpstan": "^1.9.12",
|
||||||
|
"phpstan/phpstan-phpunit": "^1.3.3",
|
||||||
|
"phpunit/php-code-coverage": "*",
|
||||||
|
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||||
|
"psalm/plugin-phpunit": "^0.16.1",
|
||||||
|
"vimeo/psalm": "^4.11",
|
||||||
|
"zumba/json-serializer": "~3.0.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance",
|
||||||
|
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/highlight-query",
|
||||||
|
"bin/lint-query",
|
||||||
|
"bin/sql-parser",
|
||||||
|
"bin/tokenize-query"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PhpMyAdmin\\SqlParser\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "The phpMyAdmin Team",
|
||||||
|
"email": "developers@phpmyadmin.net",
|
||||||
|
"homepage": "https://www.phpmyadmin.net/team/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A validating SQL lexer and parser with a focus on MySQL dialect.",
|
||||||
|
"homepage": "https://github.com/phpmyadmin/sql-parser",
|
||||||
|
"keywords": [
|
||||||
|
"analysis",
|
||||||
|
"lexer",
|
||||||
|
"parser",
|
||||||
|
"query linter",
|
||||||
|
"sql",
|
||||||
|
"sql lexer",
|
||||||
|
"sql linter",
|
||||||
|
"sql parser",
|
||||||
|
"sql syntax highlighter",
|
||||||
|
"sql tokenizer"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpmyadmin/sql-parser/issues",
|
||||||
|
"source": "https://github.com/phpmyadmin/sql-parser"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.phpmyadmin.net/donate/",
|
||||||
|
"type": "other"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-01-20T20:34:02+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpdoc-parser",
|
"name": "phpstan/phpdoc-parser",
|
||||||
"version": "1.24.2",
|
"version": "1.24.2",
|
||||||
|
|
@ -11035,6 +11224,68 @@
|
||||||
},
|
},
|
||||||
"time": "2023-09-26T12:28:12+00:00"
|
"time": "2023-09-26T12:28:12+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "1.10.57",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e",
|
||||||
|
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan-shim": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"phpstan",
|
||||||
|
"phpstan.phar"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"docs": "https://phpstan.org/user-guide/getting-started",
|
||||||
|
"forum": "https://github.com/phpstan/phpstan/discussions",
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"security": "https://github.com/phpstan/phpstan/security/policy",
|
||||||
|
"source": "https://github.com/phpstan/phpstan-src"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/ondrejmirtes",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/phpstan",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-01-24T11:51:34+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "10.1.7",
|
"version": "10.1.7",
|
||||||
|
|
|
||||||
12
phpstan.neon
Normal file
12
phpstan.neon
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
includes:
|
||||||
|
- vendor/larastan/larastan/extension.neon
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
|
||||||
|
paths:
|
||||||
|
- app/
|
||||||
|
excludePaths:
|
||||||
|
- app/Lib/vendor/
|
||||||
|
|
||||||
|
# Level 9 is the highest level
|
||||||
|
level: 5
|
||||||
|
|
@ -221,7 +221,7 @@
|
||||||
autocomplete="postal-code" required>
|
autocomplete="postal-code" required>
|
||||||
<option value="" @if (is_null(old('product'))) selected @endif>
|
<option value="" @if (is_null(old('product'))) selected @endif>
|
||||||
{{ __('Sélectionnez un produit') }}</option>
|
{{ __('Sélectionnez un produit') }}</option>
|
||||||
@foreach ($products as $product)
|
@foreach ($productModels as $product)
|
||||||
<option value="{{ $product->id }}" @if (old('product') == $product->id) selected @endif>
|
<option value="{{ $product->id }}" @if (old('product') == $product->id) selected @endif>
|
||||||
{{ $product->label }}</option>
|
{{ $product->label }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue