2f3fd laravel 11 upgrade (#436)
* fix password reset bug * upgrade to laravel 11 * composer.lock * fix migration issues * use ValidationRule Contract * rename password_resets table * implemented casts as protected function * update env variables * fix optional property * fix validation issues * use <env> on php unit xml * fix pint * cmposer.lock * composer json fixes * fix composer dependencies, remove faker * remove unused class * remove test class * fix default value for mysql migration * linting * expression syntax fix --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -89,14 +89,17 @@ class Form extends Model implements CachableAttributes
|
||||
'seo_meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'properties' => 'array',
|
||||
'database_fields_update' => 'array',
|
||||
'closes_at' => 'datetime',
|
||||
'tags' => 'array',
|
||||
'removed_properties' => 'array',
|
||||
'seo_meta' => 'object'
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'properties' => 'array',
|
||||
'database_fields_update' => 'array',
|
||||
'closes_at' => 'datetime',
|
||||
'tags' => 'array',
|
||||
'removed_properties' => 'array',
|
||||
'seo_meta' => 'object'
|
||||
];
|
||||
}
|
||||
|
||||
protected $appends = [
|
||||
'share_url',
|
||||
@@ -129,7 +132,7 @@ class Form extends Model implements CachableAttributes
|
||||
public function getIsProAttribute()
|
||||
{
|
||||
return $this->remember('is_pro', 15 * 60, function (): ?bool {
|
||||
return optional($this->workspace)->is_pro === true;
|
||||
return $this->workspace?->is_pro === true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,12 @@ class FormStatistic extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationships
|
||||
|
||||
@@ -13,9 +13,12 @@ class FormSubmission extends Model
|
||||
'data',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* RelationShips
|
||||
|
||||
@@ -23,10 +23,13 @@ class FormIntegration extends Model
|
||||
'oauth_id'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'object',
|
||||
'logic' => 'object'
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'object',
|
||||
'logic' => 'object'
|
||||
];
|
||||
}
|
||||
|
||||
protected $dispatchesEvents = [
|
||||
'created' => FormIntegrationCreated::class,
|
||||
|
||||
@@ -19,9 +19,12 @@ class FormIntegrationsEvent extends Model
|
||||
'data'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'object'
|
||||
];
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'data' => 'object'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The event map for the model.
|
||||
|
||||
@@ -20,9 +20,12 @@ class License extends Model
|
||||
'meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
];
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'meta' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
|
||||
@@ -29,15 +29,18 @@ class Template extends Model
|
||||
'related_templates',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'structure' => 'array',
|
||||
'questions' => 'array',
|
||||
'industries' => 'array',
|
||||
'types' => 'array',
|
||||
'related_templates' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'structure' => 'array',
|
||||
'questions' => 'array',
|
||||
'industries' => 'array',
|
||||
'types' => 'array',
|
||||
'related_templates' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $attributes = [
|
||||
'publicly_listed' => false,
|
||||
@@ -49,7 +52,7 @@ class Template extends Model
|
||||
|
||||
public function getShareUrlAttribute()
|
||||
{
|
||||
return front_url('/form-templates/'.$this->slug);
|
||||
return front_url('/form-templates/' . $this->slug);
|
||||
}
|
||||
|
||||
public function setDescriptionAttribute($value)
|
||||
|
||||
@@ -45,9 +45,12 @@ class User extends Authenticatable implements JWTSubject
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
@@ -90,12 +93,12 @@ class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
return $this->subscribed()
|
||||
|| in_array($this->email, config('opnform.extra_pro_users_emails'))
|
||||
|| ! is_null($this->activeLicense());
|
||||
|| !is_null($this->activeLicense());
|
||||
}
|
||||
|
||||
public function getHasCustomerIdAttribute()
|
||||
{
|
||||
return ! is_null($this->stripe_id);
|
||||
return !is_null($this->stripe_id);
|
||||
}
|
||||
|
||||
public function getAdminAttribute()
|
||||
|
||||
@@ -32,9 +32,12 @@ class Workspace extends Model implements CachableAttributes
|
||||
'is_enterprise',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'custom_domains' => 'array',
|
||||
];
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'custom_domains' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected $cachableAttributes = [
|
||||
'is_pro',
|
||||
@@ -149,7 +152,7 @@ class Workspace extends Model implements CachableAttributes
|
||||
return $this->remember('is_risky', 15 * 60, function (): bool {
|
||||
// A workspace is risky if all of his users are risky
|
||||
foreach ($this->owners as $owner) {
|
||||
if (! $owner->is_risky) {
|
||||
if (!$owner->is_risky) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
\Illuminate\Support\Facades\Gate::define('viewMailcoach', function ($user = null) {
|
||||
return optional($user)->admin;
|
||||
});
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Jhumanj\LaravelModelStats\LaravelModelStats;
|
||||
use Jhumanj\LaravelModelStats\ModelStatsServiceProvider as Provider;
|
||||
|
||||
class ModelStatsServiceProvider extends Provider
|
||||
{
|
||||
/**
|
||||
* Register the LaravelModelStats gate.
|
||||
*
|
||||
* This gate determines who can access ModelStats in non-local environments.
|
||||
*/
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewModelStats', function ($user) {
|
||||
return in_array($user->email, [
|
||||
'julien@notionforms.io',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Service\Forms\FormLogicConditionChecker;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class CustomFieldValidationRule implements Rule
|
||||
class CustomFieldValidationRule implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
@@ -36,6 +37,13 @@ class CustomFieldValidationRule implements Rule
|
||||
);
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\DataAwareRule;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FormPropertyLogicRule implements DataAwareRule, Rule
|
||||
class FormPropertyLogicRule implements DataAwareRule, ValidationRule
|
||||
{
|
||||
public const ACTIONS_VALUES = [
|
||||
'show-block',
|
||||
@@ -803,6 +804,13 @@ class FormPropertyLogicRule implements DataAwareRule, Rule
|
||||
return $this->isConditionCorrect && $this->isActionCorrect;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\DataAwareRule;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class IntegrationLogicRule implements DataAwareRule, Rule
|
||||
class IntegrationLogicRule implements DataAwareRule, ValidationRule
|
||||
{
|
||||
private $isConditionCorrect = true;
|
||||
|
||||
@@ -153,6 +154,13 @@ class IntegrationLogicRule implements DataAwareRule, Rule
|
||||
return $this->isConditionCorrect;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if(!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class OneEmailPerLine implements Rule
|
||||
class OneEmailPerLine implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
@@ -38,6 +39,13 @@ class OneEmailPerLine implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if(!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
|
||||
@@ -5,11 +5,12 @@ namespace App\Rules;
|
||||
use App\Http\Controllers\Forms\PublicFormController;
|
||||
use App\Models\Forms\Form;
|
||||
use App\Service\Storage\StorageFileNameParser;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StorageFile implements Rule
|
||||
class StorageFile implements ValidationRule
|
||||
{
|
||||
public string $error = 'Invalid file.';
|
||||
|
||||
@@ -66,6 +67,13 @@ class StorageFile implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if(!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
public function message(): string
|
||||
{
|
||||
return $this->error;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ImplicitRule;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
@@ -31,6 +32,12 @@ class ValidHCaptcha implements ImplicitRule
|
||||
'response' => $value,
|
||||
])->json('success');
|
||||
}
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if(!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class ValidPhoneInputRule implements Rule
|
||||
class ValidPhoneInputRule implements ValidationRule
|
||||
{
|
||||
public ?int $reason = 0;
|
||||
|
||||
@@ -27,6 +28,13 @@ class ValidPhoneInputRule implements Rule
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return match ($this->reason) {
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class ValidUrl implements Rule
|
||||
class ValidUrl implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
@@ -21,6 +22,13 @@ class ValidUrl implements Rule
|
||||
return preg_match($pattern, $value);
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (!$this->passes($attribute, $value)) {
|
||||
$fail($this->message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user