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 Illuminate\Auth\EloquentUserProvider;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\UserProvider as UserProviderContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -34,11 +32,11 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
|||
* @param array $credentials
|
||||
* @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
|
||||
$model = parent::retrieveByCredentials($credentials) ??
|
||||
static::retrieveTrashed($credentials);
|
||||
self::retrieveTrashed($credentials);
|
||||
|
||||
try {
|
||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
|
|
@ -77,14 +75,14 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
|||
*
|
||||
* @param UserContract $model
|
||||
* @param array $credentials
|
||||
* @return boolean
|
||||
* @return boolean|null
|
||||
* @throws \RuntimeException If model provided is not a Customer or connection to server fails.
|
||||
* @throws \LDC\LDCCRM\Exceptions\CrmException 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) {
|
||||
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
|
||||
* @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([
|
||||
'email' => $crmCustomer->email
|
||||
]);
|
||||
|
|
@ -155,7 +153,7 @@ class CrmUserProvider extends EloquentUserProvider implements UserProviderContra
|
|||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
* @throws \ErrorException If cannot connect to LDAP.
|
||||
*/
|
||||
private function retrieveTrashed(array $credentials): ?Authenticatable
|
||||
private function retrieveTrashed(array $credentials): ?\Illuminate\Contracts\Auth\Authenticatable
|
||||
{
|
||||
// * Make changes
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
@ -58,10 +58,9 @@ class ReactivateCustomerProvider extends EloquentUserProvider implements UserPro
|
|||
throw new \ErrorException('Cannot authenticate any thing else than ' . Customer::class);
|
||||
}
|
||||
|
||||
$plain = $credentials['password'];
|
||||
|
||||
/** @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
|
||||
return boolval($customer->restore());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,35 +28,35 @@ class UserCreate extends Command
|
|||
/**
|
||||
* The first name of the new user.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $first_name;
|
||||
|
||||
/**
|
||||
* The last name of the new user.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $last_name;
|
||||
|
||||
/**
|
||||
* The email of the new user.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* The password of the new user.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* The role of the new user.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $role;
|
||||
|
||||
|
|
@ -83,12 +83,12 @@ class UserCreate extends Command
|
|||
$this->addRole();
|
||||
|
||||
$user = new User([
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
'role' => $this->role,
|
||||
'published' => true,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
'role' => $this->role,
|
||||
'published' => true,
|
||||
'published_at' => Carbon::now(),
|
||||
]);
|
||||
$user->saveOrFail();
|
||||
|
|
@ -221,7 +221,7 @@ class UserCreate extends Command
|
|||
$this->role = $tmp;
|
||||
} catch (ValidationException $e) {
|
||||
$this->error(sprintf(
|
||||
'Please choose from the selection',
|
||||
'Please choose from the selection %s',
|
||||
\implode(',', collect($e->errors())->flatten()->all())
|
||||
));
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ enum ActivityLogsEventEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::created->name => 'Création',
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum ObjectEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::reclaim->name => 'Réclamation',
|
||||
|
|
|
|||
|
|
@ -260,6 +260,8 @@ enum Country: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::afghanistan->name => 'Afghanistan',
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ enum InputType: int
|
|||
case string = 11;
|
||||
case text = 12;
|
||||
case url = 13;
|
||||
/** Vimeo only */
|
||||
case videoVimeo = 14;
|
||||
/** Youtube only */
|
||||
case videoYoutube = 15;
|
||||
/** Youtube or Vimeo. */
|
||||
case video = 16;
|
||||
case videoVimeo = 14;
|
||||
case videoYoutube = 15;
|
||||
case video = 16;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum NutriscoreEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::a->name => 'A',
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ enum StaticPageType: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::contact->name => 'Contact',
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ enum BootstrapThemeEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::light->name => 'Light',
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ enum RoleEnum: int
|
|||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::conceptor->name => 'Concepteur',
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ActivityLogController extends Controller
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param App\Models\CommitmentPage $commitmentPage
|
||||
* @param \App\Models\CommitmentPage $commitmentPage
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\Game $game
|
||||
* @param \App\Models\Game $game
|
||||
* @return \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.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestone\StoreHistoricalMilestoneRequest $request
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestones\StoreHistoricalMilestoneRequest $request
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(HistoricalMilestone $historicalMilestone): \Illuminate\Contracts\View\View
|
||||
|
|
@ -111,8 +111,8 @@ class HistoricalMilestoneController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestone\UpdateHistoricalMilestoneRequest $request
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @param \App\Http\Requests\Bo\HistoricalMilestones\UpdateHistoricalMilestoneRequest $request
|
||||
* @param \App\Models\HistoricalMilestone $historicalMilestone
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class KlubBlocController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\KlubBloc $klubBloc
|
||||
* @param \App\Models\KlubBloc $klubBloc
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\LocalCommitment $localCommitment
|
||||
* @param \App\Models\LocalCommitment $localCommitment
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\News $news
|
||||
* @param \App\Models\News $news
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\Picto $picto
|
||||
* @param \App\Models\Picto $picto
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\Product $product
|
||||
* @param \App\Models\Product $product
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\Range $range
|
||||
* @param \App\Models\Range $range
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\StaticPage $static_page
|
||||
* @param \App\Models\StaticPage $static_page
|
||||
* @return \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.
|
||||
*
|
||||
* @param App\Models\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(User $user): \Illuminate\Contracts\View\View
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class Controller extends BaseController
|
|||
return $query;
|
||||
}
|
||||
// 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) {
|
||||
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
|
||||
$queryRelation->where('name', 'like', '%' . $search . '%');
|
||||
|
|
@ -132,12 +132,15 @@ class Controller extends BaseController
|
|||
*/
|
||||
protected function getSearchValue(Builder $query, string $search, string $field): string|array
|
||||
{
|
||||
$cast = $query->getModel()->getCasts()[$field] ?? null;
|
||||
if (
|
||||
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.
|
||||
enum_exists($query->getModel()->getCasts()[$field]) // Check if the cast is an enum.
|
||||
$cast and // Check if there is cast about specific field.
|
||||
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) {
|
||||
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
|
||||
});
|
||||
|
|
@ -158,12 +161,12 @@ class Controller extends BaseController
|
|||
{
|
||||
$rName = request()->route()->getName();
|
||||
$table = $query->getModel()->getTable();
|
||||
if (request()->sort_col) {
|
||||
Session::put("$rName.sort_col", request()->sort_col);
|
||||
if (request()->input('sort_col')) {
|
||||
Session::put("$rName.sort_col", request()->input('sort_col'));
|
||||
Session::put("$rName.sorted", true);
|
||||
}
|
||||
if (request()->sort_way) {
|
||||
Session::put("$rName.sort_way", request()->sort_way);
|
||||
if (request()->input('sort_way')) {
|
||||
Session::put("$rName.sort_way", request()->input('sort_way'));
|
||||
Session::put("$rName.sorted", true);
|
||||
}
|
||||
if (request()->rst) {
|
||||
|
|
@ -171,12 +174,16 @@ class Controller extends BaseController
|
|||
Session::remove("$rName.sort_col");
|
||||
Session::remove("$rName.sort_way");
|
||||
}
|
||||
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
|
||||
if (
|
||||
!isset($ignore) or
|
||||
(isset($ignore) and !in_array(request()->sort_col, $ignore))
|
||||
) {
|
||||
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
|
||||
if (
|
||||
request()->input('sort_col') and
|
||||
request()->input('sort_way') and
|
||||
Schema::hasColumn($table, request()->input('sort_col'))
|
||||
) {
|
||||
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')) {
|
||||
$query = $query->orderBy('order', 'ASC');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Controllers\Fo\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
|
@ -25,9 +24,9 @@ class ConfirmPasswordController extends Controller
|
|||
/**
|
||||
* 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()) {
|
||||
return \response()->redirectToRoute('home');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ForgotPasswordController extends Controller
|
|||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Message to user
|
||||
* Message to user.
|
||||
*
|
||||
* @var string
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class LoginController extends Controller
|
|||
*/
|
||||
protected function authenticated(Request $request, Model $user): void
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
$user->last_connection = \now();
|
||||
$user->saveOrFail();
|
||||
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\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
|
@ -47,9 +46,9 @@ class ResetPasswordController extends Controller
|
|||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @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');
|
||||
|
||||
|
|
@ -68,9 +67,6 @@ class ResetPasswordController extends Controller
|
|||
*/
|
||||
protected function resetPassword(mixed $customer, mixed $password): void
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
/** @var string $password */
|
||||
|
||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
$crm = app('crmAPI');
|
||||
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ class CommitmentController extends Controller
|
|||
->with('pictos', fn (BelongsToMany $q) => $q->where('published', true))->firstOrFail();
|
||||
|
||||
/** @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 */
|
||||
$localCommitments = LocalCommitment::query()
|
||||
/** @var \App\Models\LocalCommitment $localCommitmentModels */
|
||||
$localCommitmentModels = LocalCommitment::query()
|
||||
->where('published', true)
|
||||
->limit(2)->get();
|
||||
|
||||
return view('fo.pages.commitments', [
|
||||
'staticPageModel' => $staticPage,
|
||||
'localCommitmentList' => $localCommitments,
|
||||
'staticPageModel' => $staticPageModel,
|
||||
'localCommitmentList' => $localCommitmentModels,
|
||||
'commitmentPageModel' => $commitmentPage,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ class ContactController extends Controller
|
|||
*/
|
||||
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();
|
||||
|
||||
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
|
||||
{
|
||||
$rangeModels = Range::query()->limit(3)->inRandomOrder()->get();
|
||||
$newsModels = News::query()->where('published', true)->orderBy('created_at', 'desc')->limit(6)->get();
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
|
||||
$klubBloc = KlubBloc::query()->first();
|
||||
/** @var \App\Models\Range $rangeModels */
|
||||
$rangeModels = Range::query()->limit(3)->inRandomOrder()->get();
|
||||
|
||||
\throw_if(empty($klubBloc), 'empty klubBloc');
|
||||
/** @var \App\Models\News $newsModels */
|
||||
$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();
|
||||
|
||||
/** @var \App\Models\KlubBloc|null $klubBloc */
|
||||
$klubBloc = KlubBloc::query()->first();
|
||||
|
||||
\throw_if(is_null($klubBloc), 'empty klubBloc');
|
||||
|
||||
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\Models\Customer;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
|
@ -22,7 +21,7 @@ class CustomerController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function profile(): View
|
||||
public function profile(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('frontend')->user();
|
||||
|
|
@ -53,7 +52,7 @@ class CustomerController extends Controller
|
|||
*
|
||||
* @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');
|
||||
}
|
||||
|
|
@ -64,7 +63,7 @@ class CustomerController extends Controller
|
|||
* @param \App\Http\Requests\Fo\Customers\UpdatePasswordRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function passwordSubmit(UpdatePasswordRequest $request): RedirectResponse
|
||||
public function passwordSubmit(UpdatePasswordRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
/** @var \App\Models\Customer */
|
||||
$customer = \auth('frontend')->user();
|
||||
|
|
@ -85,7 +84,7 @@ class CustomerController extends Controller
|
|||
* @return boolean
|
||||
* @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) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ use App\Http\Requests\Fo\Customers\CrmQuestionsAnswersRequest;
|
|||
use App\Models\Customer;
|
||||
use App\Models\Game;
|
||||
use App\Models\StaticPage;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
|
|
@ -25,7 +23,7 @@ class KlubController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function home(): View
|
||||
public function home(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('frontend')->user();
|
||||
|
|
@ -47,7 +45,7 @@ class KlubController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function questions(): View
|
||||
public function questions(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('frontend')->user();
|
||||
|
|
@ -68,7 +66,7 @@ class KlubController extends Controller
|
|||
* @param \App\Http\Requests\Fo\Customers\CrmQuestionsAnswersRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function questionsSubmit(CrmQuestionsAnswersRequest $request): RedirectResponse
|
||||
public function questionsSubmit(CrmQuestionsAnswersRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
/** @var \App\Models\Customer $customer */
|
||||
$customer = auth('frontend')->user();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use Illuminate\Support\Str;
|
|||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class MesBrController extends Controller
|
||||
{
|
||||
|
|
@ -40,7 +39,7 @@ class MesBrController extends Controller
|
|||
* @param \App\Http\Requests\Fo\MesBr\PrintCouponsRequest $request
|
||||
* @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 */
|
||||
$customer = auth('frontend')->user();
|
||||
|
|
@ -89,7 +88,6 @@ class MesBrController extends Controller
|
|||
$mesBr = app('mesBrAPI');
|
||||
|
||||
// * MaJ Customer
|
||||
/** @var integer */
|
||||
retry(3, function () use ($mesBr, $crmUser) {
|
||||
/**
|
||||
* Parce que MesBr n'est pas fiable il faut retenter pour avoir
|
||||
|
|
@ -263,10 +261,10 @@ class MesBrController extends Controller
|
|||
* Fetch Crm 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.
|
||||
*/
|
||||
private function fetchCrmCustomer(Customer $customer): \LDC\LDCCRM\Models\Customer
|
||||
private function fetchCrmCustomer(Customer $customer): \LDC\LDCCRM\Models\Customer|null
|
||||
{
|
||||
try {
|
||||
$crmUser = $customer->api_data;
|
||||
|
|
@ -291,15 +289,16 @@ class MesBrController extends Controller
|
|||
report($e);
|
||||
Log::error('Unhandled response ' . $e->getApiError()->label);
|
||||
// * 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) {
|
||||
// * continue this
|
||||
throw $e;
|
||||
} catch (CrmException | \Exception $e) {
|
||||
report($e);
|
||||
// * 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
|
||||
return null;
|
||||
}
|
||||
|
||||
// * STATIC Fetch BR
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use App\Models\StaticPage;
|
|||
class StaticPageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Legal show
|
||||
* Legal show.
|
||||
*
|
||||
* @param \App\Models\StaticPage $legalPage
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
|
|
@ -24,7 +24,7 @@ class StaticPageController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Policies show
|
||||
* Policies show.
|
||||
*
|
||||
* @param \App\Models\StaticPage $policiesPage
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
|
|
@ -36,7 +36,7 @@ class StaticPageController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* HistoricalMilestone show
|
||||
* HistoricalMilestone show.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ class Kernel extends HttpKernel
|
|||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
|
||||
'crm_questions' => \App\Http\Middleware\CrmMiddlewareQuestions::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
|
||||
'crm_questions' => \App\Http\Middleware\CrmMiddlewareQuestions::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class Authenticate extends Middleware
|
|||
}
|
||||
return route('fo.login');
|
||||
}
|
||||
|
||||
return null;
|
||||
abort(401);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Http\Middleware;
|
|||
use App\Models\Customer;
|
||||
use Illuminate\Http\Request;
|
||||
use LDC\LDCCRM\Models\Question;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CrmMiddlewareQuestions
|
||||
{
|
||||
|
|
@ -17,12 +16,12 @@ class CrmMiddlewareQuestions
|
|||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @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
|
||||
/** @var \App\Models\Customer|null $user */
|
||||
if (
|
||||
\auth('frontend')->check() and
|
||||
/** @var \App\Models\Customer|null $user */
|
||||
$user = \auth('frontend')->user() and
|
||||
$user->last_connection !== null
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ class StoreGameRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false,
|
||||
'button_status' => $this->button_status ? true : false,
|
||||
'button_new_tab' => $this->button_status ? true : false,
|
||||
'published' => $this->boolean('published'),
|
||||
'button_status' => $this->boolean('button_status'),
|
||||
'button_new_tab' => $this->boolean('button_status'),
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ class StoreHistoricalMilestoneRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false,
|
||||
'button_status' => $this->button_status ? true : false,
|
||||
'button_new_tab' => $this->button_new_tab ? true : false
|
||||
'published' => $this->boolean('published'),
|
||||
'button_status' => $this->boolean('button_status'),
|
||||
'button_new_tab' => $this->boolean('button_new_tab'),
|
||||
]);
|
||||
$this->mergePicture('picture1');
|
||||
$this->mergePicture('picture2');
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class StoreLocalCommitmentRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture1');
|
||||
$this->mergePicture('picture2');
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class StoreNewsRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class StorePictoRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class StoreProductRequest extends FormRequest
|
|||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
'published' => $this->boolean('published')
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
$this->mergePicture('picture_thumbnail');
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class UpdateStaticPageRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('static_page'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class UpdateChangeOrderRequest extends FormRequest
|
|||
protected function prepareForValidation(): void
|
||||
{
|
||||
$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, [
|
||||
"data.$iptName.value" => [
|
||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
||||
return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||
ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||
}
|
||||
],
|
||||
$this->compileValidate(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class StoreUserRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('create', User::class);
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ class StoreUserRequest extends FormRequest
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published')
|
||||
|
|
@ -42,9 +42,9 @@ class StoreUserRequest extends FormRequest
|
|||
{
|
||||
return [
|
||||
'first_name' => 'required|string|min:3|max:255',
|
||||
'last_name' => 'required|string|min:3|max:255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
||||
'password' => [
|
||||
'last_name' => 'required|string|min:3|max:255',
|
||||
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
||||
'password' => [
|
||||
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
||||
->letters()
|
||||
->mixedCase()
|
||||
|
|
@ -52,8 +52,8 @@ class StoreUserRequest extends FormRequest
|
|||
->symbols()
|
||||
->uncompromised()
|
||||
],
|
||||
'role' => ['required', new Enum(RoleEnum::class)],
|
||||
'published' => 'required|boolean',
|
||||
'role' => ['required', new Enum(RoleEnum::class)],
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('user'));
|
||||
}
|
||||
|
|
@ -23,14 +23,14 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->boolean('published'),
|
||||
'password' => $this->input('password') ??
|
||||
$this->route('user')->password,
|
||||
'published' => $this->boolean('published'),
|
||||
'password' => $this->input('password') ??
|
||||
\optional($this->route('user'))->password,
|
||||
'password_confirmation' => $this->input('password_confirmation') ??
|
||||
$this->route('user')->password
|
||||
\optional($this->route('user'))->password
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -42,10 +42,10 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return array_merge(parent::rules(), [
|
||||
'email' => [
|
||||
'email' => [
|
||||
'required',
|
||||
'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' => [
|
||||
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,16 @@ use Illuminate\Validation\Rules\Enum;
|
|||
|
||||
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.
|
||||
*
|
||||
|
|
@ -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.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
return [
|
||||
|
|
@ -94,7 +94,7 @@ class ContactFormRequest extends FormRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'subject' => trans('validation.attributes.subject'),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class CreateAccountRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::guard('frontend')->check();
|
||||
}
|
||||
|
|
@ -27,10 +27,10 @@ class CreateAccountRequest extends FormRequest
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
public function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => $this->input('phone'),
|
||||
'phone' => $this->input('phone'),
|
||||
'opt_in' => $this->boolean('opt_in'),
|
||||
'ok_cgv' => $this->boolean('ok_cgv')
|
||||
]);
|
||||
|
|
@ -41,22 +41,22 @@ class CreateAccountRequest extends FormRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'phone' => 'nullable|max:255|phone:FR',
|
||||
'address' => 'required|string|min:1|max:255',
|
||||
'address2' => 'nullable|string|min:1|max:255',
|
||||
'lastname' => 'required|string|max:255',
|
||||
'firstname' => 'required|string|max:255',
|
||||
'phone' => 'nullable|max:255|phone:FR',
|
||||
'address' => 'required|string|min:1|max:255',
|
||||
'address2' => 'nullable|string|min:1|max:255',
|
||||
'postal_code' => 'required|string|min:1|postal_code:FR',
|
||||
'city' => 'required|string|min:2|max:255',
|
||||
'birth_date' => 'required|date',
|
||||
'country' => [
|
||||
'city' => 'required|string|min:2|max:255',
|
||||
'birth_date' => 'required|date',
|
||||
'country' => [
|
||||
'required', new EnumIsValidRule(Country::class),
|
||||
Rule::in(Country::getValidCountries())
|
||||
],
|
||||
'email' => [
|
||||
'email' => [
|
||||
'required', 'email:rfc,dns,spoof', 'max:255',
|
||||
// * Does email already exists in CRM ?
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
|
|
@ -67,12 +67,12 @@ class CreateAccountRequest extends FormRequest
|
|||
},
|
||||
'unique:customers,email',
|
||||
],
|
||||
'password' => [
|
||||
'password' => [
|
||||
'required', 'confirmed', Password::min(8)->mixedCase()
|
||||
->numbers()->symbols()->uncompromised()
|
||||
],
|
||||
'ok_cgv' => 'accepted',
|
||||
'opt_in' => 'required|boolean',
|
||||
'ok_cgv' => 'accepted',
|
||||
'opt_in' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -81,23 +81,23 @@ class CreateAccountRequest extends FormRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'lastname' => trans('validation.attributes.first_name'),
|
||||
'firstname' => trans('validation.attributes.first_name'),
|
||||
'phone' => trans('validation.attributes.phone'),
|
||||
'address' => trans('validation.attributes.line_address_1'),
|
||||
'address2' => trans('validation.attributes.line_address_2'),
|
||||
'country' => trans('validation.attributes.country'),
|
||||
'postal_code' => trans('validation.attributes.postal_code'),
|
||||
'city' => trans('validation.attributes.city'),
|
||||
'birth_date' => trans('validation.attributes.date_of_birth'),
|
||||
'email' => trans('validation.attributes.email'),
|
||||
'password' => trans('validation.attributes.password'),
|
||||
'lastname' => trans('validation.attributes.first_name'),
|
||||
'firstname' => trans('validation.attributes.first_name'),
|
||||
'phone' => trans('validation.attributes.phone'),
|
||||
'address' => trans('validation.attributes.line_address_1'),
|
||||
'address2' => trans('validation.attributes.line_address_2'),
|
||||
'country' => trans('validation.attributes.country'),
|
||||
'postal_code' => trans('validation.attributes.postal_code'),
|
||||
'city' => trans('validation.attributes.city'),
|
||||
'birth_date' => trans('validation.attributes.date_of_birth'),
|
||||
'email' => trans('validation.attributes.email'),
|
||||
'password' => trans('validation.attributes.password'),
|
||||
'password_confirmation' => trans('validation.attributes.password_confirmation'),
|
||||
'ok_cgv' => trans('conditions d\'utilisation'),
|
||||
'opt_in' => trans('newsletter'),
|
||||
'ok_cgv' => trans('conditions d\'utilisation'),
|
||||
'opt_in' => trans('newsletter'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -106,16 +106,16 @@ class CreateAccountRequest extends FormRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'postal_code' => trans('validation.postal_code', [
|
||||
'postal_code' => trans('validation.postal_code', [
|
||||
'countries' => \implode(', ', Country::getValidCountriesLabel()), 'examples' => 72000
|
||||
]),
|
||||
'phone.phone' => trans('validation.phone', [
|
||||
'phone.phone' => trans('validation.phone', [
|
||||
'countries' => \implode(', ', Country::getValidCountriesLabel())
|
||||
]),
|
||||
'email.unique' => trans('Un compte existe déjà avec cette adresse.'),
|
||||
'email.unique' => trans('Un compte existe déjà avec cette adresse.'),
|
||||
'ok_cgv.accepted' => trans('Vous devez accepter les conditions d\'utilisation du site pour continuer.')
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class CrmQuestionsAnswersRequest extends FormRequest
|
|||
$customer = auth('frontend')->user();
|
||||
|
||||
/** @var \LDC\LDCCRM\Models\Customer */
|
||||
// @phpstan-ignore-next-line
|
||||
$crmCustomer = $customer->apiData;
|
||||
|
||||
$this->questions = Customer::cacheCrm(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class UpdateAccountRequest extends CreateAccountRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return array_merge(
|
||||
\array_intersect_key(
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class UpdatePasswordRequest extends FormRequest
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('frontend')->check();
|
||||
}
|
||||
|
|
@ -23,16 +23,16 @@ class UpdatePasswordRequest extends FormRequest
|
|||
*
|
||||
* @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;
|
||||
return [
|
||||
'old_password' => [
|
||||
'required',
|
||||
new CrmCustomerPassword($crmCustomer)
|
||||
],
|
||||
'password' => [
|
||||
'password' => [
|
||||
'required', 'string', 'max:255', 'confirmed',
|
||||
Password::min(8)->mixedCase()->letters()->numbers()->uncompromised()
|
||||
]
|
||||
|
|
@ -44,7 +44,7 @@ class UpdatePasswordRequest extends FormRequest
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'old_password' => trans('ancien mot de passe'),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class GamesStatusUpdate
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||
$gamesListToUnPublish = Game::query()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class NewsStatusUpdate
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||
$newsListToPublish = News::query()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CollectionHelper
|
|||
* @param integer $pageSize
|
||||
* @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');
|
||||
|
||||
|
|
@ -31,8 +31,11 @@ class CollectionHelper
|
|||
* @param integer $page
|
||||
* @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();
|
||||
|
||||
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
|
||||
|
|
@ -51,8 +54,13 @@ class CollectionHelper
|
|||
* @param array $options
|
||||
* @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, [
|
||||
'items' => $items,
|
||||
'total' => $total,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class ExceptionsHelper
|
|||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
} elseif (isset($stack['function'])) {
|
||||
} else {
|
||||
$traceStr .= "{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
|
|
|
|||
|
|
@ -322,8 +322,7 @@ class FileStorageHelper
|
|||
$folderPath = self::getStoragePath(
|
||||
$private ? 'app/private/modelfiles' : 'app/public/modelfiles',
|
||||
$tableName,
|
||||
$filename,
|
||||
$private
|
||||
$filename
|
||||
);
|
||||
$filename = self::getFileUniqueName($folderPath, $filename);
|
||||
return "{$folderPath}/{$filename}";
|
||||
|
|
@ -418,7 +417,7 @@ class FileStorageHelper
|
|||
$filename = Str::of($filename)->ltrim('.-');
|
||||
// * Optional beautification
|
||||
if ($beautify) {
|
||||
$filename = static::beautifyFilename($filename);
|
||||
$filename = self::beautifyFilename($filename);
|
||||
}
|
||||
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||
/** @var string */
|
||||
|
|
|
|||
|
|
@ -175,11 +175,10 @@ class ToolboxHelper
|
|||
$url = $match;
|
||||
try {
|
||||
$request = Request::create($url);
|
||||
// If a route is match then it do not throws exception.
|
||||
if (
|
||||
\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST) &&
|
||||
$routes->match($request)
|
||||
) {
|
||||
// Assert route matches existing routes.
|
||||
$routes->match($request);
|
||||
// ? Is url internal ?
|
||||
if (\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST)) {
|
||||
// Removes the matched url.
|
||||
throw ValidationException::withMessages([
|
||||
$field => trans(
|
||||
|
|
@ -205,14 +204,14 @@ class ToolboxHelper
|
|||
* @param array|string $replace
|
||||
* @param array|string $subject
|
||||
* @param integer $count
|
||||
* @return array|string
|
||||
* @return array|string|false
|
||||
*/
|
||||
public static function mbReplace(
|
||||
array|string $search,
|
||||
array|string $replace,
|
||||
array|string $subject,
|
||||
int &$count = 0
|
||||
): array|string {
|
||||
): array|string|false {
|
||||
if (!is_array($search) && is_array($replace)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -288,10 +287,17 @@ class ToolboxHelper
|
|||
*/
|
||||
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(
|
||||
$attribute,
|
||||
// @phpstan-ignore-next-line
|
||||
$model->getLocale(),
|
||||
// @phpstan-ignore-next-line
|
||||
$model->useFallbackLocale()
|
||||
);
|
||||
}
|
||||
|
|
@ -361,47 +367,45 @@ class ToolboxHelper
|
|||
/**
|
||||
* Convert deeply an object to array
|
||||
*
|
||||
* @param array|object $input
|
||||
* @param mixed $input
|
||||
* @return array
|
||||
* @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.
|
||||
if (is_object($input) or is_array($input)) {
|
||||
$ret = (array)$input;
|
||||
foreach ($ret as &$item) {
|
||||
// Recursively process EACH element only if not scalar.
|
||||
$item = (is_object($item) or is_array($item)) ?
|
||||
self::objectToArray($item) : $item;
|
||||
}
|
||||
return $ret;
|
||||
} else {
|
||||
if (!(is_object($input) or is_array($input))) {
|
||||
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
||||
}
|
||||
$ret = (array)$input;
|
||||
foreach ($ret as &$item) {
|
||||
// Recursively process EACH element only if not scalar.
|
||||
$item = (is_object($item) or is_array($item)) ?
|
||||
self::objectToArray($item) : $item;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert deeply an array to object
|
||||
*
|
||||
* @param array|object $input
|
||||
* @param mixed $input
|
||||
* @return object
|
||||
* @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.
|
||||
if (is_object($input) or is_array($input)) {
|
||||
$ret = (object)$input;
|
||||
foreach ($ret as &$item) {
|
||||
// Recursively process EACH element only if not scalar.
|
||||
$item = (is_object($item) or is_array($item)) ?
|
||||
self::arrayToObject($item) : $item;
|
||||
}
|
||||
return $ret;
|
||||
} else {
|
||||
if (!(is_object($input) or is_array($input))) {
|
||||
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
|
||||
}
|
||||
$ret = (object)$input;
|
||||
foreach ($ret as &$item) {
|
||||
// Recursively process EACH element only if not scalar.
|
||||
$item = (is_object($item) or is_array($item)) ?
|
||||
self::arrayToObject($item) : $item;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -409,11 +413,11 @@ class ToolboxHelper
|
|||
*
|
||||
* @param string $attribute
|
||||
* @param string|null $value
|
||||
* @param callback $fail
|
||||
* @param callable $fail
|
||||
* @param object $sizes
|
||||
* @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)) {
|
||||
$fail(trans(':attribute n\'existe pas dans le système de fichier', [
|
||||
|
|
@ -421,7 +425,6 @@ class ToolboxHelper
|
|||
]));
|
||||
return;
|
||||
}
|
||||
/** @var string */
|
||||
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
|
||||
if (
|
||||
!\in_array(self::getUploadedFileMimeType($value, $useStorage), [
|
||||
|
|
@ -432,7 +435,7 @@ class ToolboxHelper
|
|||
'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', [
|
||||
'attribute' => $attribute
|
||||
]));
|
||||
|
|
@ -441,19 +444,19 @@ class ToolboxHelper
|
|||
$height = intval($dimensions[1]);
|
||||
|
||||
$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) {
|
||||
$xMessage = trans(":attribute la largeur doit être de {$sizes->minWith}px");
|
||||
if ($sizes->minWidth === $sizes->maxWidth) {
|
||||
$xMessage = trans(":attribute la largeur doit être de {$sizes->minWidth}px");
|
||||
}
|
||||
$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) {
|
||||
$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);
|
||||
}
|
||||
if (($height < $sizes->minHeight) or ($height > $sizes->maxHeight)) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SendContactMail extends Mailable
|
|||
*/
|
||||
public function __construct(\stdClass $data)
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
$this->data = clone $data;
|
||||
$this->sanitizeStringInputs();
|
||||
}
|
||||
|
|
@ -49,6 +50,7 @@ class SendContactMail extends Mailable
|
|||
*/
|
||||
private function sanitizeStringInputs(): void
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
$this->data = (object)Arr::map((array)$this->data, function ($el) {
|
||||
if (is_string($el)) {
|
||||
$el = \htmlspecialchars(\strip_tags(Blade::render(
|
||||
|
|
@ -71,8 +73,13 @@ class SendContactMail extends Mailable
|
|||
public function envelope(): \Illuminate\Mail\Mailables\Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: sprintf('%s - %s', ObjectEnum::make($this->data->type)->label() ??
|
||||
__('Nouveau message'), config('app.name')),
|
||||
subject: sprintf(
|
||||
'%s - %s',
|
||||
(isset($this->data->type)) ?
|
||||
ObjectEnum::make($this->data->type)->label() :
|
||||
__('Nouveau message'),
|
||||
config('app.name')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Enums\ActivityLogs\ActivityLogsEventEnum;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* @property string $model Target model.
|
||||
* @property string $model_id Id of the target model.
|
||||
* @property string $event Event of this activity (ActivityLogsEventEnum).
|
||||
* @property string $data Changes.
|
||||
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
||||
* @property string $model Target model.
|
||||
* @property string $model_id Id of the target model.
|
||||
* @property \App\Enums\ActivityLogs\ActivityLogsEventEnum $event Event of this activity (ActivityLogsEventEnum).
|
||||
* @property array $data Changes.
|
||||
* @property \Illuminate\Support\Carbon $created_at Created date.
|
||||
*
|
||||
* @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_id = $model->getKey();
|
||||
$activity->event = $eventEnum;
|
||||
$activity->data = static::getChangedColumns($activity, $model, $eventEnum);
|
||||
$activity->data = self::getChangedColumns($activity, $model, $eventEnum);
|
||||
$activity->created_at = Carbon::now();
|
||||
$activity->saveOrFail();
|
||||
}
|
||||
|
|
@ -89,14 +89,18 @@ class ActivityLog extends Model
|
|||
/**
|
||||
* Get old, new columns that has changed.
|
||||
*
|
||||
* @param \self $activity
|
||||
* @param \App\Models\ActivityLog $activity
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param \App\Enums\ActivityLogs\ActivityLogsEventEnum $eventEnum
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getChangedColumns(self $activity, Model $model, ActivityLogsEventEnum $eventEnum): array|null
|
||||
{
|
||||
$modelClassName = $activity->model_class;
|
||||
public static function getChangedColumns(
|
||||
ActivityLog $activity,
|
||||
Model $model,
|
||||
ActivityLogsEventEnum $eventEnum
|
||||
): array|null {
|
||||
$targetModelTypes = [];
|
||||
$modelClassName = $activity->model_class;
|
||||
/** Get type of each fields of the target model */
|
||||
$targetModel = $activity->model_class::where(
|
||||
(new $modelClassName())->getRouteKeyName(),
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use LDC\LDCCRM\Models\Customer as CrmCustomer;
|
|||
* @property string $email Email.
|
||||
* @property string $hashcode Hashcode.
|
||||
* @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 $last_connection Date de derniere connexion, (pour les questions oblig CRM).
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
|
|
@ -68,10 +68,10 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
|||
{
|
||||
// * EVENT CLOSURES.
|
||||
static::creating(function (self $model) {
|
||||
static::assertEmailIsUnique($model->id, $model->email);
|
||||
self::assertEmailIsUnique($model->id, $model->email);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
static::assertEmailIsUnique($model->id, $model->email);
|
||||
self::assertEmailIsUnique($model->id, $model->email);
|
||||
});
|
||||
static::deleted(function (self $model) {
|
||||
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.
|
||||
*
|
||||
* @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())
|
||||
->whereNull('email_verified_at');
|
||||
})->orWhere(function (Builder $q) {
|
||||
|
|
@ -173,7 +173,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
|||
return $this->api_data->activate() && parent::markEmailAsVerified();
|
||||
} catch (ApiErrorException $e) {
|
||||
if ($e->getApiError()->equals(ApiError::customerAlreadyActive())) {
|
||||
return true && parent::markEmailAsVerified();
|
||||
return parent::markEmailAsVerified();
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
|||
}
|
||||
/** @var static|null $loggedCustomer */
|
||||
$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) {
|
||||
\auth('frontend')->logout();
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
|||
public function updateApiData(array $data): bool
|
||||
{
|
||||
// phpcs:enable
|
||||
/** @var \LDC\LDCCRM\Models\Customer */
|
||||
/** @var \LDC\LDCCRM\Models\Customer|null $crmCustomer */
|
||||
$crmCustomer = $this->api_data;
|
||||
if (!$crmCustomer) {
|
||||
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)
|
||||
{
|
||||
// phpcs:enable
|
||||
// @phpstan-ignore-next-line
|
||||
return Cache::remember("customers.{$uuid}.{$part_name}", $ttl, $part);
|
||||
}
|
||||
|
||||
|
|
@ -333,24 +334,26 @@ class Customer extends Authenticatable implements MustVerifyEmail
|
|||
public function toArray()
|
||||
{
|
||||
if ($this->hashcode) {
|
||||
/** @var \LDC\LDCCRM\Models\Customer $crmCustomer */
|
||||
$crmCustomer = $this->api_data;
|
||||
return collect(array_merge(
|
||||
parent::toArray(),
|
||||
(array)$this->apiData
|
||||
(array)$crmCustomer
|
||||
))->intersectByKeys([
|
||||
'email' => '',
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'address' => '',
|
||||
'address2' => '',
|
||||
'postcode' => '',
|
||||
'email' => '',
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'address' => '',
|
||||
'address2' => '',
|
||||
'postcode' => '',
|
||||
'birth_date' => '',
|
||||
'city' => '',
|
||||
'country' => '',
|
||||
'opt_in' => '',
|
||||
'phone' => ''
|
||||
'city' => '',
|
||||
'country' => '',
|
||||
'opt_in' => '',
|
||||
'phone' => ''
|
||||
])->toArray();
|
||||
} else {
|
||||
return parent::toArray();
|
||||
}
|
||||
} //end if
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class StaticPage extends Model
|
|||
});
|
||||
static::updating(function (self $model) {
|
||||
// * ASSERTIONS
|
||||
static::assertTitleIsUnique($model->title, $model->id);
|
||||
self::assertTitleIsUnique($model->title, $model->id);
|
||||
|
||||
// * CHANGES
|
||||
$model->slug = Str::slug($model->title);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class User extends Authenticatable
|
|||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
static::updatePassword($model);
|
||||
self::updatePassword($model);
|
||||
// * Prevent user elevation privileges
|
||||
throw_if(
|
||||
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::updatePassword($model);
|
||||
self::updatePassword($model);
|
||||
if (optional(auth('backend')->user())->getKey() === $model->getKey()) {
|
||||
\validator(
|
||||
['published' => $model->published],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class DestroyCustomer extends Notification
|
|||
* @param object $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||
{
|
||||
/** @var string $firstname */
|
||||
$firstname = $notifiable->api_data->firstname;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class DestroyedCustomer extends Notification
|
|||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||
{
|
||||
// phpcs:enable
|
||||
return (new MailMessage())
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ResetPassword extends NotificationsResetPassword
|
|||
/**
|
||||
* The callback that should be used to create the reset password URL.
|
||||
*
|
||||
* @var \Closure|null
|
||||
* @var (\Closure(mixed , string ): string)|null
|
||||
*/
|
||||
public static $createUrlCallback;
|
||||
|
||||
|
|
@ -44,10 +44,10 @@ class ResetPassword extends NotificationsResetPassword
|
|||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
public function toMail($notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||
{
|
||||
// phpcs:enable
|
||||
/** @var \App\Models\Customer\Customer $notifiable */
|
||||
/** @var \App\Models\Customer $notifiable */
|
||||
$resetUrl = $this->resetUrl($notifiable);
|
||||
/** @var string $firstname */
|
||||
$firstname = $notifiable->api_data->firstname;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class UpdatePassword extends Notification
|
|||
* @param object $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||
{
|
||||
/** @var string $firstname */
|
||||
$firstname = $notifiable->api_data->firstname;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class VerifyEmail extends NotificationsVerifyEmail
|
|||
'fo.verification.verify',
|
||||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||
[
|
||||
'id' => $notifiable->getKey(),
|
||||
'id' => $notifiable->getKey(),
|
||||
'hash' => sha1($notifiable->getEmailForVerification()),
|
||||
],
|
||||
true
|
||||
|
|
@ -40,14 +40,14 @@ class VerifyEmail extends NotificationsVerifyEmail
|
|||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
public function toMail($notifiable): \Illuminate\Notifications\Messages\MailMessage
|
||||
{
|
||||
// phpcs:enable
|
||||
/** @var \App\Models\Customer\Customer $notifiable */
|
||||
/** @var \App\Models\Customer $notifiable */
|
||||
$verificationUrl = $this->verificationUrl($notifiable);
|
||||
$firstname = $notifiable->api_data->firstname;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
return $user->role === RoleEnum::conceptor;
|
||||
});
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
$this->app->auth->provider('crm', function ($app, array $config) {
|
||||
return new CrmUserProvider($app['hash'], $config['model']);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class TranslationServiceProvider extends ServiceProvider
|
|||
/**
|
||||
* Gather provided langs checking from files
|
||||
*
|
||||
* @return \Illuminate\Support\Collection<string, string>
|
||||
* @return \Illuminate\Support\Collection<int, string>
|
||||
*/
|
||||
private function collectLocalesStrings(): Collection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Traits\Controllers;
|
||||
|
||||
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -14,33 +14,22 @@ trait ChangesModelOrder
|
|||
* Change order.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\UpdateChangeOrderRequest $request
|
||||
* @param mixed ...$params
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @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);
|
||||
$className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly();
|
||||
$className = "\\App\\Models\\{$className}";
|
||||
$model = Arr::get($params, $paramNames->count() - 2);
|
||||
$params = collect(request()->route()->parameterNames);
|
||||
$className = Str::ucfirst(Str::lower($params->get($params->count() - 2)));
|
||||
$className = "\\App\\Models\\$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 */
|
||||
$model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first();
|
||||
$model = $className::where($model->getRouteKeyName(), $model->getRouteKey())->first();
|
||||
|
||||
if (!$model) {
|
||||
return back()->with('error', trans('crud.messages.order_not_changed'));
|
||||
|
|
@ -48,18 +37,16 @@ trait ChangesModelOrder
|
|||
|
||||
return DB::transaction(function () use ($request, $className, $model) {
|
||||
/** @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();
|
||||
|
||||
if (!$tmp) {
|
||||
return back()->with('error', trans('crud.messages.order_not_changed'));
|
||||
}
|
||||
|
||||
$newOrder = $tmp->order;
|
||||
$tmp->order = $model->order;
|
||||
$model->order = $newOrder;
|
||||
$tmp->saveOrFail();
|
||||
$model->saveOrFail();
|
||||
$newOrder = $tmp->getOriginal('order');
|
||||
$tmp->update(['order' => $model->getOriginal('order')]);
|
||||
$model->update(['order' => $newOrder]);
|
||||
Session::flash('success', trans('crud.messages.order_changed'));
|
||||
|
||||
return back();
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ trait UpdateModelPublished
|
|||
*/
|
||||
public function changePublished(Model $model)
|
||||
{
|
||||
$model->published = !$model->published;
|
||||
$model->saveOrFail();
|
||||
$model->update(['published' => !$model->getOriginal('published')]);
|
||||
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,9 +118,9 @@ trait BaseEnum
|
|||
/**
|
||||
* Fetch enum using value.
|
||||
*
|
||||
* @param \App\Traits\Enums\BaseEnum|integer|string $value
|
||||
* @param string $field
|
||||
* @return \App\Traits\Enums\BaseEnum|null
|
||||
* @param self|integer|string $value
|
||||
* @param string $field
|
||||
* @return 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.)
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
|
@ -18,9 +19,9 @@ trait IsCachedAsCollection
|
|||
* Get all available instances from cache.
|
||||
* 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())) {
|
||||
try {
|
||||
|
|
@ -34,7 +35,7 @@ trait IsCachedAsCollection
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove cached elements
|
||||
* Remove cached elements.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -52,7 +53,8 @@ trait IsCachedAsCollection
|
|||
{
|
||||
$conditions = [];
|
||||
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())
|
||||
->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
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected static function queryCached(Builder $query): Builder
|
||||
protected static function queryCached(Builder $query): \Illuminate\Database\Eloquent\Builder
|
||||
{
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change query for cached elements
|
||||
* Change query for cached elements.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $results
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected static function filterQuery(Collection $results): Collection
|
||||
protected static function filterQuery(Collection $results): \Illuminate\Support\Collection
|
||||
{
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class basename
|
||||
* Get the class basename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -92,7 +94,7 @@ trait IsCachedAsCollection
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the class basename
|
||||
* Get the class basename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ trait HasPicture
|
|||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $minWith = 400;
|
||||
private $minWidth = 400;
|
||||
|
||||
/**
|
||||
* Maximum width
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $maxWith = 1800;
|
||||
private $maxWidth = 1800;
|
||||
|
||||
/**
|
||||
* Minimum height
|
||||
|
|
@ -41,32 +41,41 @@ trait HasPicture
|
|||
* Image rules
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer|null $minWith
|
||||
* @param integer|null $minWidth
|
||||
* @param integer|null $minHeight
|
||||
* @param integer|null $maxWith
|
||||
* @param integer|null $maxWidth
|
||||
* @param integer|null $maxHeight
|
||||
* @param boolean $nullable
|
||||
* @param integer|null $size
|
||||
* @param string|null $requiredWith
|
||||
* @param string|null $requiredWithout
|
||||
* @return array
|
||||
*/
|
||||
public function pictureRules(
|
||||
string $name = 'picture',
|
||||
?int $minWith = null,
|
||||
?int $minWidth = null,
|
||||
?int $minHeight = null,
|
||||
?int $maxWith = null,
|
||||
?int $maxWidth = null,
|
||||
?int $maxHeight = null,
|
||||
bool $nullable = false
|
||||
bool $nullable = false,
|
||||
?int $size = null,
|
||||
?string $requiredWith = null,
|
||||
?string $requiredWithout = null,
|
||||
): array {
|
||||
$sizes = (object)[
|
||||
'minWith' => $minWith ?? $this->minWith,
|
||||
$dimensions = (object)[
|
||||
'minWidth' => $minWidth ?? $this->minWidth,
|
||||
'minHeight' => $minHeight ?? $this->minHeight,
|
||||
'maxWith' => $maxWith ?? $this->maxWith,
|
||||
'maxWidth' => $maxWidth ?? $this->maxWidth,
|
||||
'maxHeight' => $maxHeight ?? $this->maxHeight
|
||||
];
|
||||
return [
|
||||
$name => [
|
||||
!$nullable ? 'required' : 'nullable',
|
||||
function (string $attribute, $value, callable $fail) use ($sizes) {
|
||||
return ToolboxHelper::validatePicture($attribute, $value, $fail, $sizes);
|
||||
(strlen($requiredWith)) ? 'required_with:' . $requiredWith : '',
|
||||
(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
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer|null $minWith
|
||||
* @param integer|null $minWidth
|
||||
* @param integer|null $minHeight
|
||||
* @param integer|null $maxWith
|
||||
* @param integer|null $maxWidth
|
||||
* @param integer|null $maxHeight
|
||||
* @return array
|
||||
*/
|
||||
public function picturesRules(
|
||||
string $name = 'pictures',
|
||||
?int $minWith = null,
|
||||
?int $minWidth = null,
|
||||
?int $minHeight = null,
|
||||
?int $maxWith = null,
|
||||
?int $maxWidth = null,
|
||||
?int $maxHeight = null
|
||||
): array {
|
||||
$sizes = (object)[
|
||||
'minWith' => $minWith ?? $this->minWith,
|
||||
'minWidth' => $minWidth ?? $this->minWidth,
|
||||
'minHeight' => $minHeight ?? $this->minHeight,
|
||||
'maxWith' => $maxWith ?? $this->maxWith,
|
||||
'maxWidth' => $maxWidth ?? $this->maxWidth,
|
||||
'maxHeight' => $maxHeight ?? $this->maxHeight
|
||||
];
|
||||
return [
|
||||
|
|
@ -101,7 +110,7 @@ trait HasPicture
|
|||
"{$name}Validate.*" => [
|
||||
'required',
|
||||
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": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"larastan/larastan": "^2.8",
|
||||
"laravel-lang/common": "^4.0",
|
||||
"laravel/pint": "^1.0",
|
||||
"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",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b72fd73d510285ac10b0b17fe78928c9",
|
||||
"content-hash": "c5101a95c61f5cc18999a10e3cfa6190",
|
||||
"packages": [
|
||||
{
|
||||
"name": "axlon/laravel-postal-code-validation",
|
||||
|
|
@ -10024,6 +10024,107 @@
|
|||
},
|
||||
"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",
|
||||
"version": "2.5.0",
|
||||
|
|
@ -10988,6 +11089,94 @@
|
|||
},
|
||||
"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",
|
||||
"version": "1.24.2",
|
||||
|
|
@ -11035,6 +11224,68 @@
|
|||
},
|
||||
"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",
|
||||
"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>
|
||||
<option value="" @if (is_null(old('product'))) selected @endif>
|
||||
{{ __('Sélectionnez un produit') }}</option>
|
||||
@foreach ($products as $product)
|
||||
@foreach ($productModels as $product)
|
||||
<option value="{{ $product->id }}" @if (old('product') == $product->id) selected @endif>
|
||||
{{ $product->label }}</option>
|
||||
@endforeach
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue