fix hinting and tests for L10 and PHP8
This commit is contained in:
@@ -142,9 +142,9 @@ class ArticleConductor extends Conductor
|
|||||||
* Transform the Hero field.
|
* Transform the Hero field.
|
||||||
*
|
*
|
||||||
* @param mixed $value The current value.
|
* @param mixed $value The current value.
|
||||||
* @return array The new value.
|
* @return array|null The new value.
|
||||||
*/
|
*/
|
||||||
public function transformHero(mixed $value): array
|
public function transformHero(mixed $value): array|null
|
||||||
{
|
{
|
||||||
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
|
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,9 +519,9 @@ class Conductor
|
|||||||
* @param Request $request The request data.
|
* @param Request $request The request data.
|
||||||
* @param string $key The key prefix to use.
|
* @param string $key The key prefix to use.
|
||||||
* @param Model|null $model The model.
|
* @param Model|null $model The model.
|
||||||
* @return array The processed and transformed model data.
|
* @return array|null The processed and transformed model data.
|
||||||
*/
|
*/
|
||||||
final public static function includeModel(Request $request, string $key, mixed $model): array
|
final public static function includeModel(Request $request, string $key, mixed $model): array|null
|
||||||
{
|
{
|
||||||
$fields = [];
|
$fields = [];
|
||||||
|
|
||||||
@@ -547,9 +547,9 @@ class Conductor
|
|||||||
*
|
*
|
||||||
* @param mixed $fields The fields to show.
|
* @param mixed $fields The fields to show.
|
||||||
* @param Model|null $model The model.
|
* @param Model|null $model The model.
|
||||||
* @return array The processed and transformed model data.
|
* @return array|null The processed and transformed model data.
|
||||||
*/
|
*/
|
||||||
final public static function model(mixed $fields, mixed $model): array
|
final public static function model(mixed $fields, mixed $model): array|null
|
||||||
{
|
{
|
||||||
if ($model === null) {
|
if ($model === null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ class EventConductor extends Conductor
|
|||||||
* Transform the Hero field.
|
* Transform the Hero field.
|
||||||
*
|
*
|
||||||
* @param mixed $value The current value.
|
* @param mixed $value The current value.
|
||||||
* @return array The new value.
|
* @return array|null The new value.
|
||||||
*/
|
*/
|
||||||
public function transformHero(mixed $value): array
|
public function transformHero(mixed $value): array|null
|
||||||
{
|
{
|
||||||
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
|
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ class Authenticate extends Middleware
|
|||||||
* Get the path the user should be redirected to when they are not authenticated.
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
*
|
*
|
||||||
* @param mixed $request Request.
|
* @param mixed $request Request.
|
||||||
|
* @return ?string
|
||||||
*/
|
*/
|
||||||
protected function redirectTo(mixed $request): ?string
|
protected function redirectTo(mixed $request): ?string
|
||||||
{
|
{
|
||||||
if ($request->expectsJson() === false) {
|
if ($request->expectsJson() === false) {
|
||||||
return route('login');
|
return route('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ namespace App\Models;
|
|||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
|
||||||
use App\Traits\Uuids;
|
use App\Traits\Uuids;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
@@ -79,6 +81,8 @@ class User extends Authenticatable implements Auditable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of files of the user
|
* Get the list of files of the user
|
||||||
|
*
|
||||||
|
* @return Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
*/
|
*/
|
||||||
public function permissions(): HasMany
|
public function permissions(): HasMany
|
||||||
{
|
{
|
||||||
@@ -87,6 +91,8 @@ class User extends Authenticatable implements Auditable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the permission attribute
|
* Get the permission attribute
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getPermissionsAttribute(): array
|
public function getPermissionsAttribute(): array
|
||||||
{
|
{
|
||||||
@@ -97,6 +103,7 @@ class User extends Authenticatable implements Auditable
|
|||||||
* Test if user has permission
|
* Test if user has permission
|
||||||
*
|
*
|
||||||
* @param string $permission Permission to test.
|
* @param string $permission Permission to test.
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasPermission(string $permission): bool
|
public function hasPermission(string $permission): bool
|
||||||
{
|
{
|
||||||
@@ -107,6 +114,7 @@ class User extends Authenticatable implements Auditable
|
|||||||
* Give permissions to the user
|
* Give permissions to the user
|
||||||
*
|
*
|
||||||
* @param string|array $permissions The permission(s) to give.
|
* @param string|array $permissions The permission(s) to give.
|
||||||
|
* @return Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function givePermission($permissions): Collection
|
public function givePermission($permissions): Collection
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user