Compare commits

...

18 Commits

Author SHA1 Message Date
James Collins
4f536ae5a9 Merge branch 'main' into shift-91885 2023-05-25 07:46:59 +10:00
James Collins
95395d1da7 Merge pull request #50 from STEMMechanics/shift-91887
Laravel Consolidate Namespaces Shift
2023-05-25 07:38:32 +10:00
Shift
fbf437ac99 Shift cleanup 2023-05-24 21:33:19 +00:00
Shift
5faf49688d Remove redundant typing from DocBlocks 2023-05-24 21:33:17 +00:00
Shift
4d7d0ed74d Add type hints from DocBlocks 2023-05-24 21:33:16 +00:00
Shift
979b9f704c Add type hints for Laravel 10 2023-05-24 21:33:15 +00:00
Shift
4124cf39db Set return type of base TestCase methods
From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html
2023-05-24 21:33:13 +00:00
Shift
c83e21d588 Rename password_resets table 2023-05-24 21:33:13 +00:00
Shift
c88630e9af Adopt anonymous migrations 2023-05-24 21:33:12 +00:00
Shift
40b265e145 Bump Laravel dependencies 2023-05-24 21:33:11 +00:00
Shift
3ad2b2fb8e Default config files
In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.
2023-05-24 21:33:11 +00:00
Shift
8b671065e9 Shift config files 2023-05-24 21:33:11 +00:00
Shift
028e1a191e Shift core files 2023-05-24 21:33:08 +00:00
Shift
a133f82997 Remove explicit call to register policies 2023-05-24 21:33:00 +00:00
Shift
c4f3eb9a4e Remove default lang files 2023-05-24 21:32:59 +00:00
Shift
8a52c4529f Use Faker methods
Accessing Faker properties was deprecated in Faker 1.14.
2023-05-24 21:32:59 +00:00
Shift
d0493f3dd0 Convert string references to ::class
PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
2023-05-24 21:32:58 +00:00
Shift
b845552c37 Apply code style 2023-05-24 21:32:56 +00:00
127 changed files with 445 additions and 1058 deletions

View File

@@ -19,7 +19,7 @@ class AnalyticsConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Analytics';
protected $class = \App\Models\Analytics::class;
/**
* The default sorting field
@@ -41,7 +41,7 @@ class AnalyticsConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow model to be visible.
*/
public static function viewable(Model $model)
public static function viewable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/analytics') === true);
@@ -52,7 +52,7 @@ class AnalyticsConductor extends Conductor
*
* @return boolean Allow creating model.
*/
public static function creatable()
public static function creatable(): bool
{
return true;
}
@@ -63,7 +63,7 @@ class AnalyticsConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/analytics') === true);
@@ -75,7 +75,7 @@ class AnalyticsConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/analytics') === true);

View File

@@ -19,7 +19,7 @@ class ArticleConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Article';
protected $class = \App\Models\Article::class;
/**
* The default sorting field
@@ -39,9 +39,8 @@ class ArticleConductor extends Conductor
* Run a scope query on the collection before anything else.
*
* @param Builder $builder The builder in use.
* @return void
*/
public function scope(Builder $builder)
public function scope(Builder $builder): void
{
$user = auth()->user();
if ($user === null || $user->hasPermission('admin/articles') === false) {
@@ -56,7 +55,7 @@ class ArticleConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow model to be visible.
*/
public static function viewable(Model $model)
public static function viewable(Model $model): bool
{
if (Carbon::parse($model->publish_at)->isFuture() === true) {
$user = auth()->user();
@@ -73,7 +72,7 @@ class ArticleConductor extends Conductor
*
* @return boolean Allow creating model.
*/
public static function creatable()
public static function creatable(): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/articles') === true);
@@ -85,7 +84,7 @@ class ArticleConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/articles') === true);
@@ -97,7 +96,7 @@ class ArticleConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/articles') === true);
@@ -109,7 +108,7 @@ class ArticleConductor extends Conductor
* @param array $data The model data to transform.
* @return array The transformed model.
*/
public function transformFinal(array $data)
public function transformFinal(array $data): array
{
unset($data['user_id']);
return $data;
@@ -145,7 +144,7 @@ class ArticleConductor extends Conductor
* @param mixed $value The current value.
* @return array The new value.
*/
public function transformHero(mixed $value)
public function transformHero(mixed $value): array
{
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
}

View File

@@ -81,7 +81,7 @@ class Conductor
* @param string $string The string to split.
* @return array The split string.
*/
private function splitString(string $string)
private function splitString(string $string): array
{
$parts = [];
$start = 0;
@@ -143,9 +143,8 @@ class Conductor
*
* @param Request $request The user request.
* @param array|null $limitFields A list of fields to limit the filter request to.
* @return void
*/
private function filter(Request $request, array|null $limitFields = null)
private function filter(Request $request, array|null $limitFields = null): void
{
if (is_array($limitFields) === true && count($limitFields) === 0) {
$limitFields = null;
@@ -210,10 +209,8 @@ class Conductor
/**
* Apple the filter array to the collection.
*
* @return void
*/
final public function applyFilters()
final public function applyFilters(): void
{
$parseFunc = function ($filterArray, $query) use (&$parseFunc) {
$item = null;
@@ -365,7 +362,7 @@ class Conductor
* @param Request $request The request data.
* @return array The processed and transformed collection | the total rows found.
*/
final public static function request(Request $request)
final public static function request(Request $request): array
{
$conductor_class = get_called_class();
$conductor = new $conductor_class();
@@ -457,7 +454,7 @@ class Conductor
* @param Collection $collection The collection.
* @return array The processed and transformed model data.
*/
final public static function collection(Request $request, Collection $collection)
final public static function collection(Request $request, Collection $collection): array
{
$conductor_class = get_called_class();
$conductor = new $conductor_class();
@@ -503,9 +500,8 @@ class Conductor
* @param Builder $query The custom query.
* @param Request $request The request.
* @param array|null $limitFields Limit the request to these fields.
* @return Builder
*/
public static function filterQuery(Builder $query, Request $request, array|null $limitFields = null)
public static function filterQuery(Builder $query, Request $request, array|null $limitFields = null): Builder
{
$conductor_class = get_called_class();
$conductor = new $conductor_class();
@@ -525,7 +521,7 @@ class Conductor
* @param Model|null $model The model.
* @return array The processed and transformed model data.
*/
final public static function includeModel(Request $request, string $key, mixed $model)
final public static function includeModel(Request $request, string $key, mixed $model): array
{
$fields = [];
@@ -553,7 +549,7 @@ class Conductor
* @param Model|null $model The model.
* @return array The processed and transformed model data.
*/
final public static function model(mixed $fields, mixed $model)
final public static function model(mixed $fields, mixed $model): array
{
if ($model === null) {
return null;
@@ -606,7 +602,7 @@ class Conductor
*
* @return integer The current collection count.
*/
final public function count()
final public function count(): int
{
if ($this->query !== null) {
return $this->query->count();
@@ -619,9 +615,8 @@ class Conductor
* Sort the conductor collection.
*
* @param mixed $fields A field name or array of field names to sort. Supports prefix of +/- to change direction.
* @return void
*/
final public function sort(mixed $fields = null)
final public function sort(mixed $fields = null): void
{
$collectionSort = [];
@@ -698,9 +693,8 @@ class Conductor
*
* @param Model $model The model to append.
* @param array $includes The list of includes to include.
* @return void
*/
final public function applyIncludes(Model $model, array $includes)
final public function applyIncludes(Model $model, array $includes): void
{
foreach ($includes as $include) {
$includeMethodName = 'include' . Str::studly($include);
@@ -718,9 +712,8 @@ class Conductor
* Limit the returned fields in the conductor collection.
*
* @param array $fields An array of field names.
* @return void
*/
final public function limitFields(array $fields)
final public function limitFields(array $fields): void
{
if (empty($fields) !== true) {
$this->query->select(array_diff($fields, $this->includes));
@@ -733,9 +726,8 @@ class Conductor
* @param string $rawFilter The raw filter string to parse.
* @param array|null $limitFields The fields to allow in the filter string.
* @param string $outerJoin The join for this filter group.
* @return void
*/
final public function appendFilterString(string $rawFilter, array|null $limitFields = null, string $outerJoin = 'OR')
final public function appendFilterString(string $rawFilter, array|null $limitFields = null, string $outerJoin = 'OR'): void
{
if ($rawFilter === '') {
return;
@@ -847,9 +839,8 @@ class Conductor
* @param string $operator The operator to append.
* @param string $value The value to append.
* @param string $join The join to append.
* @return void
*/
final public function appendFilter(string $field, string $operator, string $value, string $join = 'OR')
final public function appendFilter(string $field, string $operator, string $value, string $join = 'OR'): void
{
if (count($this->filterArray) !== 0) {
$this->filterArray[] = $join;
@@ -861,9 +852,8 @@ class Conductor
* Run a scope query on the collection before anything else.
*
* @param Builder $builder The builder in use.
* @return void
*/
public function scope(Builder $builder)
public function scope(Builder $builder): void
{
}
@@ -873,7 +863,7 @@ class Conductor
* @param Model $model The model in question.
* @return array The array of field names.
*/
public function fields(Model $model)
public function fields(Model $model): array
{
$visibleFields = $model->getVisible();
if (empty($visibleFields) === true) {
@@ -900,7 +890,7 @@ class Conductor
* @param Model $model The model to transform.
* @return array The transformed model.
*/
protected function transformModel(Model $model)
protected function transformModel(Model $model): array
{
$result = $this->transform($model);
foreach ($result as $key => $value) {
@@ -920,7 +910,7 @@ class Conductor
* @param Model $model The model to transform.
* @return array The transformed model.
*/
public function transform(Model $model)
public function transform(Model $model): array
{
$result = $model->toArray();
@@ -939,7 +929,7 @@ class Conductor
* @param array $data The model array to transform.
* @return array The transformed model.
*/
public function transformFinal(array $data)
public function transformFinal(array $data): array
{
return $data;
}
@@ -950,7 +940,7 @@ class Conductor
* @param Model $model The model in question.
* @return boolean Is the model viewable.
*/
public static function viewable(Model $model)
public static function viewable(Model $model): bool
{
return true;
}
@@ -960,7 +950,7 @@ class Conductor
*
* @return boolean Is the model creatable.
*/
public static function creatable()
public static function creatable(): bool
{
return true;
}
@@ -971,7 +961,7 @@ class Conductor
* @param Model $model The model in question.
* @return boolean Is the model updatable.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
return true;
}
@@ -982,7 +972,7 @@ class Conductor
* @param Model $model The model in question.
* @return boolean Is the model destroyable.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
return true;
}

View File

@@ -14,7 +14,7 @@ class EventConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Event';
protected $class = \App\Models\Event::class;
/**
* The default sorting field
@@ -33,9 +33,8 @@ class EventConductor extends Conductor
* Run a scope query on the collection before anything else.
*
* @param Builder $builder The builder in use.
* @return void
*/
public function scope(Builder $builder)
public function scope(Builder $builder): void
{
$user = auth()->user();
if ($user === null || $user->hasPermission('admin/events') === false) {
@@ -51,7 +50,7 @@ class EventConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow model to be visible.
*/
public static function viewable(Model $model)
public static function viewable(Model $model): bool
{
if (strtolower($model->status) === 'draft' || Carbon::parse($model->publish_at)->isFuture() === true) {
$user = auth()->user();
@@ -68,7 +67,7 @@ class EventConductor extends Conductor
*
* @return boolean Allow creating model.
*/
public static function creatable()
public static function creatable(): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/events') === true);
@@ -80,7 +79,7 @@ class EventConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/events') === true);
@@ -92,7 +91,7 @@ class EventConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/events') === true);
@@ -121,7 +120,7 @@ class EventConductor extends Conductor
* @param mixed $value The current value.
* @return array The new value.
*/
public function transformHero(mixed $value)
public function transformHero(mixed $value): array
{
return MediaConductor::includeModel(request(), 'hero', Media::find($value));
}

View File

@@ -12,7 +12,7 @@ class MediaConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Media';
protected $class = \App\Models\Media::class;
/**
* The default sorting field
@@ -43,7 +43,7 @@ class MediaConductor extends Conductor
* @param Model $model The model in question.
* @return array The array of field names.
*/
public function fields(Model $model)
public function fields(Model $model): array
{
$fields = parent::fields($model);
@@ -59,9 +59,8 @@ class MediaConductor extends Conductor
* Run a scope query on the collection before anything else.
*
* @param Builder $builder The builder in use.
* @return void
*/
public function scope(Builder $builder)
public function scope(Builder $builder): void
{
$user = auth()->user();
if ($user === null) {
@@ -77,7 +76,7 @@ class MediaConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow model to be visible.
*/
public static function viewable(Model $model)
public static function viewable(Model $model): bool
{
if ($model->permission !== '') {
$user = auth()->user();
@@ -94,7 +93,7 @@ class MediaConductor extends Conductor
*
* @return boolean Allow creating model.
*/
public static function creatable()
public static function creatable(): bool
{
$user = auth()->user();
return ($user !== null);
@@ -106,7 +105,7 @@ class MediaConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && (strcasecmp($model->user_id, $user->id) === 0 || $user->hasPermission('admin/media') === true));
@@ -118,7 +117,7 @@ class MediaConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && ($model->user_id === $user->id || $user->hasPermission('admin/media') === true));
@@ -130,7 +129,7 @@ class MediaConductor extends Conductor
* @param array $data The model data to transform.
* @return array The transformed model.
*/
public function transformFinal(array $data)
public function transformFinal(array $data): array
{
unset($data['user_id']);
return $data;

View File

@@ -12,7 +12,7 @@ class ShortlinkConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Shortlink';
protected $class = \App\Models\Shortlink::class;
/**
* The default sorting field
@@ -26,7 +26,7 @@ class ShortlinkConductor extends Conductor
*
* @return boolean Allow creating model.
*/
public static function creatable()
public static function creatable(): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/shortlinks') === true);
@@ -38,7 +38,7 @@ class ShortlinkConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/shortlinks') === true);
@@ -50,7 +50,7 @@ class ShortlinkConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/shortlinks') === true);

View File

@@ -10,7 +10,7 @@ class SubscriptionConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\Subscription';
protected $class = \App\Models\Subscription::class;
/**
@@ -19,7 +19,7 @@ class SubscriptionConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && ((strcasecmp($model->email, $user->email) === 0 && $user->email_verified_at !== null) || $user->hasPermission('admin/subscriptions') === true));
@@ -31,7 +31,7 @@ class SubscriptionConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && ((strcasecmp($model->email, $user->email) === 0 && $user->email_verified_at !== null) || $user->hasPermission('admin/subscriptions') === true));

View File

@@ -10,7 +10,7 @@ class UserConductor extends Conductor
* The Model Class
* @var string
*/
protected $class = '\App\Models\User';
protected $class = \App\Models\User::class;
/**
@@ -19,7 +19,7 @@ class UserConductor extends Conductor
* @param Model $model The model.
* @return string[] The fields visible.
*/
public function fields(Model $model)
public function fields(Model $model): array
{
$user = auth()->user();
if ($user === null || $user->hasPermission('admin/users') === false) {
@@ -35,7 +35,7 @@ class UserConductor extends Conductor
* @param Model $model The model to transform.
* @return array The transformed model.
*/
public function transform(Model $model)
public function transform(Model $model): array
{
$user = auth()->user();
$data = $model->toArray();
@@ -56,7 +56,7 @@ class UserConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow updating model.
*/
public static function updatable(Model $model)
public static function updatable(Model $model): bool
{
$user = auth()->user();
if ($user !== null) {
@@ -72,7 +72,7 @@ class UserConductor extends Conductor
* @param Model $model The model.
* @return boolean Allow deleting model.
*/
public static function destroyable(Model $model)
public static function destroyable(Model $model): bool
{
$user = auth()->user();
return ($user !== null && $user->hasPermission('admin/users') === true);

View File

@@ -27,10 +27,8 @@ class MediaMigrate extends Command
/**
* Configure the command options.
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->addOption(
'replace',
@@ -42,10 +40,8 @@ class MediaMigrate extends Command
/**
* Execute the console command.
*
* @return void
*/
public function handle()
public function handle(): void
{
$replace = $this->option('replace');

View File

@@ -26,10 +26,8 @@ class MediaRebuild extends Command
/**
* Configure the command options.
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->addOption(
'replace',
@@ -48,10 +46,8 @@ class MediaRebuild extends Command
/**
* Execute the console command.
*
* @return void
*/
public function handle()
public function handle(): void
{
$replace = $this->option('replace');
$all = $this->option('replace');

View File

@@ -11,19 +11,16 @@ class Kernel extends ConsoleKernel
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule The schedule.
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');

View File

@@ -12,24 +12,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
@@ -44,10 +26,8 @@ class Handler extends ExceptionHandler
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
public function register(): void
{
// $this->renderable(function (HttpException $e, $request) {
// if ($request->is('api/*')) {

View File

@@ -11,7 +11,7 @@ class SubscriptionFilter extends FilterAbstract
*
* @var mixed
*/
protected $class = '\App\Models\Subscription';
protected $class = \App\Models\Subscription::class;
/**

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\JsonResponse;
use App\Enum\HttpResponseCodes;
use App\Http\Controllers\Controller;
use Illuminate\Database\Eloquent\Model;
@@ -23,9 +24,8 @@ class ApiController extends Controller
* @param array $data Response data.
* @param integer $respondCode Response status code.
* @param array $headers Response headers.
* @return \Illuminate\Http\JsonResponse
*/
public function respondJson(array $data, int $respondCode = HttpResponseCodes::HTTP_OK, array $headers = [])
public function respondJson(array $data, int $respondCode = HttpResponseCodes::HTTP_OK, array $headers = []): JsonResponse
{
return response()->json($data, $respondCode, $headers);
}
@@ -34,9 +34,8 @@ class ApiController extends Controller
* Return forbidden message
*
* @param string $message Response message.
* @return \Illuminate\Http\JsonResponse
*/
public function respondForbidden(string $message = 'You do not have permission to access the resource.')
public function respondForbidden(string $message = 'You do not have permission to access the resource.'): JsonResponse
{
return response()->json(['message' => $message], HttpResponseCodes::HTTP_FORBIDDEN);
}
@@ -45,9 +44,8 @@ class ApiController extends Controller
* Return forbidden message
*
* @param string $message Response message.
* @return \Illuminate\Http\JsonResponse
*/
public function respondNotFound(string $message = 'The resource was not found.')
public function respondNotFound(string $message = 'The resource was not found.'): JsonResponse
{
return response()->json(['message' => $message], HttpResponseCodes::HTTP_NOT_FOUND);
}
@@ -56,36 +54,32 @@ class ApiController extends Controller
* Return too large message
*
* @param string $message Response message.
* @return \Illuminate\Http\JsonResponse
*/
public function respondTooLarge(string $message = 'The request entity is too large.')
public function respondTooLarge(string $message = 'The request entity is too large.'): JsonResponse
{
return response()->json(['message' => $message], HttpResponseCodes::HTTP_REQUEST_ENTITY_TOO_LARGE);
}
/**
* Return no content
* @return \Illuminate\Http\JsonResponse
*/
public function respondNoContent()
public function respondNoContent(): JsonResponse
{
return response()->json([], HttpResponseCodes::HTTP_NO_CONTENT);
}
/**
* Return created
* @return \Illuminate\Http\JsonResponse
*/
public function respondCreated()
public function respondCreated(): JsonResponse
{
return response()->json([], HttpResponseCodes::HTTP_CREATED);
}
/**
* Return accepted
* @return \Illuminate\Http\JsonResponse
*/
public function respondAccepted()
public function respondAccepted(): JsonResponse
{
return response()->json([], HttpResponseCodes::HTTP_ACCEPTED);
}
@@ -95,9 +89,8 @@ class ApiController extends Controller
*
* @param string $message Error message.
* @param integer $responseCode Resource code.
* @return \Illuminate\Http\JsonResponse
*/
public function respondError(string $message, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY)
public function respondError(string $message, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY): JsonResponse
{
return response()->json([
'message' => $message
@@ -109,9 +102,8 @@ class ApiController extends Controller
*
* @param array $errors Error messages.
* @param integer $responseCode Resource code.
* @return \Illuminate\Http\JsonResponse
*/
public function respondWithErrors(array $errors, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY)
public function respondWithErrors(array $errors, int $responseCode = HttpResponseCodes::HTTP_UNPROCESSABLE_ENTITY): JsonResponse
{
$keys = array_keys($errors);
$error = $errors[$keys[0]];
@@ -132,13 +124,12 @@ class ApiController extends Controller
*
* @param array|Model|Collection $data Resource data.
* @param array $options Respond options.
* @return \Illuminate\Http\JsonResponse
*/
protected function respondAsResource(
mixed $data,
array $options = [],
$validationFn = null
) {
): JsonResponse {
$isCollection = $options['isCollection'] ?? false;
$appendData = $options['appendData'] ?? null;
$resourceName = $options['resourceName'] ?? null;

View File

@@ -126,7 +126,7 @@ class ArticleController extends ApiController
* @throws BindingResolutionException
* @throws InvalidCastException
*/
public function getAttachments(Request $request, Article $article)
public function getAttachments(Request $request, Article $article): JsonResponse
{
if (ArticleConductor::viewable($article) === true) {
$medium = $article->attachments->map(function ($attachment) {
@@ -148,7 +148,7 @@ class ArticleController extends ApiController
* @throws BindingResolutionException
* @throws MassAssignmentException
*/
public function storeAttachment(Request $request, Article $article)
public function storeAttachment(Request $request, Article $article): JsonResponse
{
if (ArticleConductor::updatable($article) === true) {
if ($request->has("medium") && Media::find($request->medium)) {
@@ -167,11 +167,10 @@ class ArticleController extends ApiController
*
* @param Request $request The user request.
* @param Article $article The related model.
* @return JsonResponse
* @throws BindingResolutionException
* @throws MassAssignmentException
*/
public function updateAttachments(Request $request, Article $article)
public function updateAttachments(Request $request, Article $article): JsonResponse
{
if (ArticleConductor::updatable($article) === true) {
$mediaIds = $request->attachments;
@@ -216,10 +215,9 @@ class ArticleController extends ApiController
* @param Request $request The user request.
* @param Article $article The model.
* @param Media $medium The attachment medium.
* @return JsonResponse
* @throws BindingResolutionException
*/
public function deleteAttachment(Request $request, Article $article, Media $medium)
public function deleteAttachment(Request $request, Article $article, Media $medium): JsonResponse
{
if (ArticleConductor::updatable($article) === true) {
$attachments = $article->attachments;

View File

@@ -31,9 +31,8 @@ class AuthController extends ApiController
* Current User details
*
* @param Request $request Current request data.
* @return JsonResponse
*/
public function me(Request $request)
public function me(Request $request): JsonResponse
{
$user = $request->user()->makeVisible(['permissions']);
return $this->respondAsResource($user);
@@ -87,9 +86,8 @@ class AuthController extends ApiController
* Logout current user
*
* @param Request $request Current request data.
* @return JsonResponse
*/
public function logout(Request $request)
public function logout(Request $request): JsonResponse
{
$user = $request->user();

View File

@@ -116,7 +116,7 @@ class EventController extends ApiController
* @param Event $event The event model.
* @return JsonResponse Returns the event attachments.
*/
public function getAttachments(Request $request, Event $event)
public function getAttachments(Request $request, Event $event): JsonResponse
{
if (EventConductor::viewable($event) === true) {
$medium = $event->attachments->map(function ($attachment) {
@@ -136,7 +136,7 @@ class EventController extends ApiController
* @param Event $event The event model.
* @return JsonResponse The response.
*/
public function storeAttachment(Request $request, Event $event)
public function storeAttachment(Request $request, Event $event): JsonResponse
{
if (EventConductor::updatable($event) === true) {
if ($request->has("medium") === true && Media::find($request->medium) !== null) {
@@ -155,9 +155,8 @@ class EventController extends ApiController
*
* @param Request $request The user request.
* @param Event $event The related model.
* @return JsonResponse
*/
public function updateAttachments(Request $request, Event $event)
public function updateAttachments(Request $request, Event $event): JsonResponse
{
if (EventConductor::updatable($event) === true) {
$mediaIds = $request->attachments;
@@ -203,9 +202,8 @@ class EventController extends ApiController
* @param Request $request The user request.
* @param Event $event The model.
* @param Media $medium The attachment medium.
* @return JsonResponse
*/
public function deleteAttachment(Request $request, Event $event, Media $medium)
public function deleteAttachment(Request $request, Event $event, Media $medium): JsonResponse
{
if (EventConductor::updatable($event) === true) {
$attachments = $event->attachments;

View File

@@ -145,9 +145,8 @@ class UserController extends ApiController
* Register a new user
*
* @param \App\Http\Requests\UserRegisterRequest $request The register user request.
* @return \Illuminate\Http\Response
*/
public function register(UserRegisterRequest $request)
public function register(UserRegisterRequest $request): JsonResponse
{
try {
$userData = $request->only([
@@ -286,9 +285,8 @@ class UserController extends ApiController
* Resend a new verify email
*
* @param \App\Http\Requests\UserResendVerifyEmailRequest $request The resend verify email request.
* @return \Illuminate\Http\Response
*/
public function resendVerifyEmail(UserResendVerifyEmailRequest $request)
public function resendVerifyEmail(UserResendVerifyEmailRequest $request): JsonResponse
{
UserCode::clearExpired();
@@ -340,9 +338,8 @@ class UserController extends ApiController
*
* @param Request $request The http request.
* @param User $user The specified user.
* @return JsonResponse
*/
public function eventList(Request $request, User $user)
public function eventList(Request $request, User $user): JsonResponse
{
if ($request->user() !== null && ($request->user() === $user || $request->user()->hasPermission('admin/events') === true)) {
$collection = $user->events;

View File

@@ -3,13 +3,11 @@
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}

View File

@@ -40,7 +40,7 @@ class Kernel extends HttpKernel
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
// \App\Http\Middleware\ForceJsonResponse::class,
'useSanctumGuard',
@@ -49,13 +49,13 @@ class Kernel extends HttpKernel
];
/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
* Aliases may be used to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,

View File

@@ -10,9 +10,8 @@ class Authenticate extends Middleware
* Get the path the user should be redirected to when they are not authenticated.
*
* @param mixed $request Request.
* @return string|null
*/
protected function redirectTo(mixed $request)
protected function redirectTo(mixed $request): ?string
{
if ($request->expectsJson() === false) {
return route('login');

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Closure;
use Illuminate\Http\Request;
@@ -10,11 +11,9 @@ class ForceJsonResponse
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$request->headers->set('Accept', 'application/json');
return $next($request);

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Closure;
use Illuminate\Http\Request;
use App\Models\Analytics;
@@ -11,11 +12,9 @@ class LogRequest
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
// Make it an after middleware
$response = $next($request);

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
@@ -13,11 +14,10 @@ class RedirectIfAuthenticated
* Handle an incoming request.
*
* @param Request $request Request.
* @param Closure(Request): (Response|RedirectResponse) $next Next.
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards Guards.
* @return Response|RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) === true ? [null] : $guards;

View File

@@ -11,7 +11,7 @@ class TrustHosts extends Middleware
*
* @return array<int, string|null>
*/
public function hosts()
public function hosts(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -11,11 +12,9 @@ class UseSanctumGuard
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
Auth::shouldUse('sanctum');
return $next($request);

View File

@@ -11,7 +11,7 @@ class AnalyticsRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function postRules()
public function postRules(): array
{
return [
'type' => 'required|string',
@@ -23,7 +23,7 @@ class AnalyticsRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function putRules()
public function putRules(): array
{
return [
'type' => 'string',

View File

@@ -11,7 +11,7 @@ class ArticleRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function postRules()
public function postRules(): array
{
return [
'slug' => 'required|string|min:6|unique:articles',
@@ -28,7 +28,7 @@ class ArticleRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function putRules()
public function putRules(): array
{
return [
'slug' => [

View File

@@ -11,7 +11,7 @@ class AuthLoginRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'email' => 'required|string|min:6|max:255',

View File

@@ -9,10 +9,8 @@ class BaseRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
if (request()->isMethod('post') === true && method_exists($this, 'postAuthorize') === true) {
return $this->postAuthorize();
@@ -30,7 +28,7 @@ class BaseRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
$rules = [];
@@ -54,9 +52,8 @@ class BaseRequest extends FormRequest
*
* @param array $collection1 The first collection of rules.
* @param array $collection2 The second collection of rules to merge.
* @return array
*/
private function mergeRules(array $collection1, array $collection2)
private function mergeRules(array $collection1, array $collection2): array
{
$rules = [];

View File

@@ -12,7 +12,7 @@ class ContactSendRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'name' => 'required|max:255',

View File

@@ -11,7 +11,7 @@ class EventRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function baseRules()
public function baseRules(): array
{
return [
'title' => 'min:6',
@@ -42,7 +42,7 @@ class EventRequest extends BaseRequest
*
* @return array<string, mixed>
*/
protected function postRules()
protected function postRules(): array
{
return [
'title' => 'required',

View File

@@ -11,7 +11,7 @@ class ShortlinkRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function postRules()
public function postRules(): array
{
return [
'code' => 'required|string|max:255|min:2|unique:shortlinks',
@@ -24,7 +24,7 @@ class ShortlinkRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function putRules()
public function putRules(): array
{
$shortlink = $this->route('shortlink');

View File

@@ -11,7 +11,7 @@ class SubscriptionRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function postRules()
public function postRules(): array
{
return [
'email' => 'required|email|unique:subscriptions',
@@ -24,7 +24,7 @@ class SubscriptionRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function destroyRules()
public function destroyRules(): array
{
return [
'email' => 'required|email',
@@ -34,10 +34,8 @@ class SubscriptionRequest extends BaseRequest
/**
* Get the custom error messages.
*
* @return array
*/
public function messages()
public function messages(): array
{
return [
'email.unique' => 'This email address has already subscribed',

View File

@@ -12,7 +12,7 @@ class UserForgotPasswordRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'email' => 'required|exists:users,email',

View File

@@ -12,7 +12,7 @@ class UserRegisterRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'display_name' => ['required','string','max:255', new Uniqueish('users')],

View File

@@ -15,7 +15,7 @@ class UserRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function postRules()
public function postRules(): array
{
$user = auth()->user();
$isAdminUser = $user->hasPermission('admin/users');
@@ -40,7 +40,7 @@ class UserRequest extends BaseRequest
*
* @return array<string, mixed>
*/
public function putRules()
public function putRules(): array
{
$user = auth()->user();
$ruleUser = $this->route('user');

View File

@@ -12,7 +12,7 @@ class UserResendVerifyEmailRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'email' => 'required|exists:users,email',

View File

@@ -12,7 +12,7 @@ class UserResetPasswordRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'code' => 'required|digits:6',

View File

@@ -12,7 +12,7 @@ class UserVerifyEmailRequest extends FormRequest
*
* @return array<string, mixed>
*/
public function rules()
public function rules(): array
{
return [
'code' => 'required|digits:6',

View File

@@ -48,10 +48,8 @@ class MoveMediaJob implements ShouldQueue
/**
* Execute the job.
*
* @return void
*/
public function handle()
public function handle(): void
{
// Don't continue if the media is already on the new storage disk
if ($this->media->storage === $this->newStorage) {

View File

@@ -47,10 +47,8 @@ class SendEmailJob implements ShouldQueue
/**
* Execute the job.
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->to)->send($this->mailable);
}

View File

@@ -62,10 +62,8 @@ class StoreUploadedFileJob implements ShouldQueue
/**
* Execute the job.
*
* @return void
*/
public function handle()
public function handle(): void
{
$storageDisk = $this->media->storage;
$fileName = $this->media->name;

View File

@@ -54,10 +54,8 @@ class ChangeEmailVerify extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '👋🏻 Lets change your email!',
@@ -66,10 +64,8 @@ class ChangeEmailVerify extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.change_email_verify',

View File

@@ -54,10 +54,8 @@ class ChangedEmail extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '👍 Your email has been changed!',
@@ -66,10 +64,8 @@ class ChangedEmail extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.changed_email',

View File

@@ -36,10 +36,8 @@ class ChangedPassword extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '👍 Your password has been changed!',
@@ -48,10 +46,8 @@ class ChangedPassword extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.changed_password',

View File

@@ -53,10 +53,8 @@ class Contact extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: config('contact.contact_subject'),
@@ -65,10 +63,8 @@ class Contact extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.contact',

View File

@@ -45,10 +45,8 @@ class EmailVerify extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '👋🏻 Welcome to STEMMechanics!',
@@ -57,10 +55,8 @@ class EmailVerify extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.email_verify',

View File

@@ -45,10 +45,8 @@ class ForgotPassword extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '🤦 Forgot your password?',
@@ -57,10 +55,8 @@ class ForgotPassword extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.forgot_password',

View File

@@ -36,10 +36,8 @@ class SubscriptionConfirm extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: '🗞️ You\'re on the mailing list!',
@@ -48,10 +46,8 @@ class SubscriptionConfirm extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.subscription_confirm',

View File

@@ -36,10 +36,8 @@ class SubscriptionUnsubscribed extends Mailable
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
public function envelope(): Envelope
{
return new Envelope(
subject: 'You have been unsubscribed',
@@ -48,10 +46,8 @@ class SubscriptionUnsubscribed extends Mailable
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
public function content(): Content
{
return new Content(
view: 'emails.user.subscription_unsubscribed',

View File

@@ -22,9 +22,8 @@ class Analytics extends Model
* automatically assigning a session value based on previous rows.
*
* @param array $attributes Model attributes.
* @return static
*/
public static function createWithSession(array $attributes)
public static function createWithSession(array $attributes): static
{
$previousRow = self::where('useragent', $attributes['useragent'])
->where('ip', $attributes['ip'])

View File

@@ -29,21 +29,17 @@ class Article extends Model
/**
* Get the article user
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get all of the article's attachments.
*
* @return MorphMany
*/
public function attachments()
public function attachments(): MorphMany
{
return $this->morphMany('App\Models\Attachment', 'attachable');
return $this->morphMany(\App\Models\Attachment::class, 'attachable');
}
}

View File

@@ -33,20 +33,16 @@ class Attachment extends Model
/**
* Get attachments attachable
*
* @return MorphTo
*/
public function attachable()
public function attachable(): MorphTo
{
return $this->morphTo();
}
/**
* Get the media for this attachment.
*
* @return BelongsTo
*/
public function media()
public function media(): BelongsTo
{
return $this->belongsTo(Media::class);
}

View File

@@ -38,20 +38,16 @@ class Event extends Model
/**
* Get all of the article's attachments.
*
* @return MorphMany
*/
public function attachments()
public function attachments(): MorphMany
{
return $this->morphMany('App\Models\Attachment', 'attachable');
return $this->morphMany(\App\Models\Attachment::class, 'attachable');
}
/**
* Get all the associated users.
*
* @return BelongsToMany
*/
public function users()
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class, 'event_user', 'event_id', 'user_id');
}

View File

@@ -24,20 +24,16 @@ class EventUser extends Model
/**
* Get the event for this attachment.
*
* @return BelongsTo
*/
public function event()
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
/**
* Get the user for this attachment.
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -100,10 +100,8 @@ class Media extends Model
/**
* Model Boot
*
* @return void
*/
protected static function boot()
protected static function boot(): void
{
parent::boot();
@@ -136,7 +134,7 @@ class Media extends Model
* @param string $type The variant type to get.
* @return array The variant data.
*/
public static function getTypeVariants(string $type)
public static function getTypeVariants(string $type): array
{
if (isset(self::$variantTypes[$type]) === true) {
return self::$variantTypes[$type];
@@ -151,7 +149,7 @@ class Media extends Model
* @param mixed $value The value to mutate.
* @return array The mutated value.
*/
public function getVariantsAttribute(mixed $value)
public function getVariantsAttribute(mixed $value): array
{
if (is_string($value) === true) {
return json_decode($value, true);
@@ -164,9 +162,8 @@ class Media extends Model
* Variants Set Mutator.
*
* @param mixed $value The value to mutate.
* @return void
*/
public function setVariantsAttribute(mixed $value)
public function setVariantsAttribute(mixed $value): void
{
if (is_array($value) !== true) {
$value = [];
@@ -182,7 +179,7 @@ class Media extends Model
* @param string $variant The initial variant.
* @return string The previous variant name (or '').
*/
public function getPreviousVariant(string $type, string $variant)
public function getPreviousVariant(string $type, string $variant): string
{
if (isset(self::$variantTypes[$type]) === false) {
return '';
@@ -206,7 +203,7 @@ class Media extends Model
* @param string $variant The initial variant.
* @return string The next variant name (or '').
*/
public function getNextVariant(string $type, string $variant)
public function getNextVariant(string $type, string $variant): string
{
if (isset(self::$variantTypes[$type]) === false) {
return '';
@@ -230,7 +227,7 @@ class Media extends Model
* @param boolean $returnNearest Return the nearest variant if request is not found.
* @return string The URL.
*/
public function getVariantURL(string $variant, bool $returnNearest = true)
public function getVariantURL(string $variant, bool $returnNearest = true): string
{
$variants = $this->variants;
if (isset($variants[$variant]) === true) {
@@ -256,10 +253,8 @@ class Media extends Model
/**
* Delete file and associated files with the modal.
*
* @return void
*/
public function deleteFile()
public function deleteFile(): void
{
$fileName = $this->name;
$baseName = pathinfo($fileName, PATHINFO_FILENAME);
@@ -279,10 +274,9 @@ class Media extends Model
/**
* Invalidate Cloudflare Cache.
*
* @return void
* @throws InvalidArgumentException Exception.
*/
private function invalidateCFCache()
private function invalidateCFCache(): void
{
$zone_id = env("CLOUDFLARE_ZONE_ID");
$api_key = env("CLOUDFLARE_API_KEY");
@@ -311,10 +305,8 @@ class Media extends Model
/**
* Get URL path
*
* @return string
*/
public function getUrlPath()
public function getUrlPath(): string
{
$url = config("filesystems.disks.$this->storage.url");
return "$url/";
@@ -322,10 +314,8 @@ class Media extends Model
/**
* Return the file URL
*
* @return string
*/
public function getUrlAttribute()
public function getUrlAttribute(): string
{
if (isset($this->attributes['name']) === true) {
return self::getUrlPath() . $this->name;
@@ -336,10 +326,8 @@ class Media extends Model
/**
* Return the file owner
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
@@ -348,9 +336,8 @@ class Media extends Model
* Move files to new storage device.
*
* @param string $storage The storage ID to move to.
* @return void
*/
public function moveToStorage(string $storage)
public function moveToStorage(string $storage): void
{
if ($storage !== $this->storage && Config::has("filesystems.disks.$storage") === true) {
$this->status = "Processing media";
@@ -366,7 +353,7 @@ class Media extends Model
* @param Illuminate\Http\UploadedFile $file The file.
* @return null|Media The result or null if not successful.
*/
public static function createFromUploadedFile(Request $request, UploadedFile $file)
public static function createFromUploadedFile(Request $request, UploadedFile $file): ?Media
{
$request->merge([
'title' => $request->get('title', ''),
@@ -401,7 +388,7 @@ class Media extends Model
* @param Illuminate\Http\UploadedFile $file The file.
* @return null|Media The media item.
*/
public function updateWithUploadedFile(UploadedFile $file)
public function updateWithUploadedFile(UploadedFile $file): ?Media
{
if ($file === null || $file->isValid() !== true) {
throw new \Exception('The file is invalid.', self::INVALID_FILE_ERROR);
@@ -494,10 +481,8 @@ class Media extends Model
/**
* Get the server maximum upload size
*
* @return integer
*/
public static function getMaxUploadSize()
public static function getMaxUploadSize(): int
{
$sizes = [
ini_get('upload_max_filesize'),
@@ -561,7 +546,7 @@ class Media extends Model
* @param boolean $ignoreCache Ignore the file list cache.
* @return boolean If the file exists on any storage disks.
*/
public static function fileExistsInStorage(string $fileName, bool $ignoreCache = false)
public static function fileExistsInStorage(string $fileName, bool $ignoreCache = false): bool
{
$disks = array_keys(Config::get('filesystems.disks'));
@@ -608,7 +593,7 @@ class Media extends Model
* @param string $fileName The file name to test.
* @return boolean If the file name contains the special suffix.
*/
public static function fileNameHasSuffix(string $fileName)
public static function fileNameHasSuffix(string $fileName): bool
{
$suffix = '/(-\d+x\d+|-scaled)$/i';
$fileNameWithoutExtension = pathinfo($fileName, PATHINFO_FILENAME);
@@ -620,9 +605,8 @@ class Media extends Model
* Sanitize fileName for upload
*
* @param string $fileName Filename to sanitize.
* @return string
*/
private static function sanitizeFilename(string $fileName)
private static function sanitizeFilename(string $fileName): string
{
/*
# file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words

View File

@@ -24,10 +24,8 @@ class Permission extends Model
/**
* Get the User associated with this model
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -79,20 +79,16 @@ class User extends Authenticatable implements Auditable
/**
* Get the list of files of the user
*
* @return HasMany
*/
public function permissions()
public function permissions(): HasMany
{
return $this->hasMany(Permission::class);
}
/**
* Get the permission attribute
*
* @return array
*/
public function getPermissionsAttribute()
public function getPermissionsAttribute(): array
{
return $this->permissions()->pluck('permission')->toArray();
}
@@ -101,9 +97,8 @@ class User extends Authenticatable implements Auditable
* Test if user has permission
*
* @param string $permission Permission to test.
* @return boolean
*/
public function hasPermission(string $permission)
public function hasPermission(string $permission): bool
{
return ($this->permissions()->where('permission', $permission)->first() !== null);
}
@@ -112,9 +107,8 @@ class User extends Authenticatable implements Auditable
* Give permissions to the user
*
* @param string|array $permissions The permission(s) to give.
* @return Collection
*/
public function givePermission($permissions)
public function givePermission($permissions): Collection
{
if (is_array($permissions) === false) {
$permissions = [$permissions];
@@ -137,9 +131,8 @@ class User extends Authenticatable implements Auditable
* Revoke permissions from the user
*
* @param string|array $permissions The permission(s) to revoke.
* @return integer
*/
public function revokePermission($permissions)
public function revokePermission($permissions): int
{
if (is_array($permissions) === false) {
$permissions = [$permissions];
@@ -152,50 +145,40 @@ class User extends Authenticatable implements Auditable
/**
* Get the list of files of the user
*
* @return HasMany
*/
public function media()
public function media(): HasMany
{
return $this->hasMany(Media::class);
}
/**
* Get the list of files of the user
*
* @return HasMany
*/
public function articles()
public function articles(): HasMany
{
return $this->hasMany(Article::class);
}
/**
* Get associated user codes
*
* @return HasMany
*/
public function codes()
public function codes(): HasMany
{
return $this->hasMany(UserCode::class);
}
/**
* Get the list of logins of the user
*
* @return HasMany
*/
public function logins()
public function logins(): HasMany
{
return $this->hasMany(UserLogins::class);
}
/**
* Get the events associated with the user.
*
* @return BelongsToMany
*/
public function events()
public function events(): BelongsToMany
{
return $this->belongsToMany(Event::class, 'event_user', 'user_id', 'event_id');
}

View File

@@ -23,10 +23,8 @@ class UserCode extends Model
/**
* Boot function from Laravel.
*
* @return void
*/
protected static function boot()
protected static function boot(): void
{
parent::boot();
static::creating(function ($model) {
@@ -46,10 +44,8 @@ class UserCode extends Model
/**
* Generate new code
*
* @return void
*/
public function regenerate()
public function regenerate(): void
{
while (true) {
$code = random_int(100000, 999999);
@@ -62,20 +58,16 @@ class UserCode extends Model
/**
* Clear expired user codes
*
* @return void
*/
public static function clearExpired()
public static function clearExpired(): void
{
UserCode::where('updated_at', '<=', now()->subDays(5))->delete();
}
/**
* Get associated user
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -28,10 +28,8 @@ class UserLogins extends Model
/**
* Get the file user
*
* @return BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -16,20 +16,16 @@ class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
Storage::macro('public', function ($diskName) {
$public = config("filesystems.disks.{$diskName}.public", false);

View File

@@ -19,13 +19,9 @@ class AuthServiceProvider extends ServiceProvider
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->registerPolicies();
//
}
}

View File

@@ -9,10 +9,8 @@ class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
Broadcast::routes();

View File

@@ -26,20 +26,16 @@ class EventServiceProvider extends ServiceProvider
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
public function boot(): void
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*
* @return boolean
*/
public function shouldDiscoverEvents()
public function shouldDiscoverEvents(): bool
{
return false;
}

View File

@@ -23,12 +23,32 @@ class RouteServiceProvider extends ServiceProvider
/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->configureRateLimiting();
// RateLimiter::for('api', function (Request $request) {
// return Limit::perMinute(60)->by($request->user()?->id !== null ?: $request->ip());
// });
$rateLimitEnabled = true;
$user = auth()->user();
if (app()->environment('testing')) {
$rateLimitEnabled = false;
} elseif ($user !== null && $user->hasPermission('admin/ratelimit') === true) {
// Admin users with the "admin/ratelimit" permission are not rate limited
$rateLimitEnabled = false;
}
if ($rateLimitEnabled === true) {
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(180)->by($request->user()?->id ?: $request->ip());
});
} else {
RateLimiter::for('api', function () {
return Limit::none();
});
}
$this->routes(function () {
Route::middleware('api')
@@ -55,36 +75,4 @@ class RouteServiceProvider extends ServiceProvider
->name("{{$singularUri}}.attachments.destroy");
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
// RateLimiter::for('api', function (Request $request) {
// return Limit::perMinute(60)->by($request->user()?->id !== null ?: $request->ip());
// });
$rateLimitEnabled = true;
$user = auth()->user();
if (app()->environment('testing')) {
$rateLimitEnabled = false;
} elseif ($user !== null && $user->hasPermission('admin/ratelimit') === true) {
// Admin users with the "admin/ratelimit" permission are not rate limited
$rateLimitEnabled = false;
}
if ($rateLimitEnabled === true) {
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(180)->by($request->user()?->id ?: $request->ip());
});
} else {
RateLimiter::for('api', function () {
return Limit::none();
});
}
}
}

View File

@@ -22,9 +22,8 @@ class Recaptcha implements Rule
*
* @param mixed $attribute Attribute name.
* @param mixed $value Attribute value.
* @return boolean
*/
public function passes(mixed $attribute, mixed $value)
public function passes(mixed $attribute, mixed $value): bool
{
$endpoint = config('services.google_recaptcha');
@@ -42,10 +41,8 @@ class Recaptcha implements Rule
/**
* Get the validation error message.
*
* @return string
*/
public function message()
public function message(): string
{
return 'Captcha failed. Refresh the page and try again';
}

View File

@@ -20,21 +20,17 @@ class UniqueFileName implements Rule
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return boolean
*/
public function passes($attribute, $value)
public function passes(string $attribute, $value): bool
{
return (Media::fileExists($value) === false);
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
public function message(): string
{
return 'The file name already exists.';
}

View File

@@ -47,9 +47,8 @@ class Uniqueish implements Rule
* Set the ID of the record to be ignored.
*
* @param mixed $id The ID to ignore.
* @return $this
*/
public function ignore(mixed $id)
public function ignore(mixed $id): static
{
$this->ignoreId = $id;
return $this;
@@ -60,9 +59,8 @@ class Uniqueish implements Rule
*
* @param mixed $attribute Not used.
* @param mixed $value The value to compare.
* @return boolean
*/
public function passes(mixed $attribute, mixed $value)
public function passes(mixed $attribute, mixed $value): bool
{
$columnName = ($this->column ?? $attribute);
$similarValue = preg_replace('/[^A-Za-z]/', '', strtolower($value));
@@ -97,10 +95,8 @@ class Uniqueish implements Rule
/**
* Get the validation error message.
*
* @return string
*/
public function message()
public function message(): string
{
return 'The :attribute is similar to one that already exists. Please choose another.';
}

View File

@@ -11,7 +11,7 @@ class AnimatedGifService
* @param integer $dataSize GIF blob size.
* @return boolean GIF file/blob is animated.
*/
public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0)
public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0): bool
{
$regex = '#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s';
$count = 0;
@@ -41,10 +41,8 @@ class AnimatedGifService
* @param string $filenameOrBlob GIF filename path
* @param integer $dataSize GIF blob size.
* @param boolean $originalFrames Get original frames (with transparent background)
*
* @return array
*/
public function extract(string $filenameOrBlob, int $dataSize = 0, $originalFrames = false)
public function extract(string $filenameOrBlob, int $dataSize = 0, bool $originalFrames = false): array
{
if (self::isAnimatedGif($filenameOrBlob) === false) {
return [];
@@ -198,7 +196,7 @@ class GifFrameExtractor
*
* @param string $filename GIF filename path
*/
private function parseFramesInfo($filename)
private function parseFramesInfo(string $filename)
{
$this->openFile($filename);
$this->parseGifHeader();
@@ -275,10 +273,8 @@ class GifFrameExtractor
/**
* Parse the graphic extension of the frames (old: get_graphics_extension)
*
* @param integer $type
*/
private function parseGraphicsExtension($type)
private function parseGraphicsExtension(int $type)
{
$startdata = $this->readByte(2);
@@ -303,10 +299,8 @@ class GifFrameExtractor
/**
* Get the full frame string block (old: get_image_block)
*
* @param integer $type
*/
private function getFrameString($type)
private function getFrameString(int $type)
{
if ($this->checkByte(0x2c)) {
$start = $this->pointer;
@@ -400,14 +394,8 @@ class GifFrameExtractor
/**
* Get the image data byte (old: get_imagedata_byte)
*
* @param string $type
* @param integer $start
* @param integer $length
*
* @return string
*/
private function getImageDataByte($type, $start, $length)
private function getImageDataByte(string $type, int $start, int $length): string
{
if ($type == "ext") {
return substr($this->frameSources[$this->frameNumber]["graphicsextension"], $start, $length);
@@ -419,15 +407,8 @@ class GifFrameExtractor
/**
* Get the image data bit (old: get_imagedata_bit)
*
* @param string $type
* @param integer $byteIndex
* @param integer $bitStart
* @param integer $bitLength
*
* @return number
*/
private function getImageDataBit($type, $byteIndex, $bitStart, $bitLength)
private function getImageDataBit(string $type, int $byteIndex, int $bitStart, int $bitLength): number
{
if ($type == "ext") {
return $this->readBits(ord(substr($this->frameSources[$this->frameNumber]["graphicsextension"], $byteIndex, 1)), $bitStart, $bitLength);
@@ -439,12 +420,8 @@ class GifFrameExtractor
/**
* Return the value of 2 ASCII chars (old: dualbyteval)
*
* @param string $s
*
* @return integer
*/
private function dualByteVal($s)
private function dualByteVal(string $s): int
{
$i = (ord($s[1]) * 256 + ord($s[0]));
@@ -453,10 +430,8 @@ class GifFrameExtractor
/**
* Read the data stream (old: read_data_stream)
*
* @param integer $firstLength
*/
private function readDataStream($firstLength)
private function readDataStream(int $firstLength)
{
$this->pointerForward($firstLength);
$length = $this->readByteInt();
@@ -471,10 +446,8 @@ class GifFrameExtractor
/**
* Open the gif file (old: loadfile)
*
* @param string $filename
*/
private function openFile($filename)
private function openFile(string $filename)
{
$this->handle = fopen($filename, "rb");
$this->pointer = 0;
@@ -495,12 +468,8 @@ class GifFrameExtractor
/**
* Read the file from the beginning to $byteCount in binary (old: readbyte)
*
* @param integer $byteCount
*
* @return string
*/
private function readByte($byteCount)
private function readByte(int $byteCount): string
{
$data = fread($this->handle, $byteCount);
$this->pointer += $byteCount;
@@ -510,10 +479,8 @@ class GifFrameExtractor
/**
* Read a byte and return ASCII value (old: readbyte_int)
*
* @return integer
*/
private function readByteInt()
private function readByteInt(): int
{
$data = fread($this->handle, 1);
$this->pointer++;
@@ -523,14 +490,8 @@ class GifFrameExtractor
/**
* Convert a $byte to decimal (old: readbits)
*
* @param string $byte
* @param integer $start
* @param integer $length
*
* @return number
*/
private function readBits($byte, $start, $length)
private function readBits(string $byte, int $start, int $length): number
{
$bin = str_pad(decbin($byte), 8, "0", STR_PAD_LEFT);
$data = substr($bin, $start, $length);
@@ -540,10 +501,8 @@ class GifFrameExtractor
/**
* Rewind the file pointer reader (old: p_rewind)
*
* @param integer $length
*/
private function pointerRewind($length)
private function pointerRewind(int $length)
{
$this->pointer -= $length;
fseek($this->handle, $this->pointer);
@@ -551,10 +510,8 @@ class GifFrameExtractor
/**
* Forward the file pointer reader (old: p_forward)
*
* @param integer $length
*/
private function pointerForward($length)
private function pointerForward(int $length)
{
$this->pointer += $length;
fseek($this->handle, $this->pointer);
@@ -562,13 +519,8 @@ class GifFrameExtractor
/**
* Get a section of the data from $start to $start + $length (old: datapart)
*
* @param integer $start
* @param integer $length
*
* @return string
*/
private function dataPart($start, $length)
private function dataPart(int $start, int $length): string
{
fseek($this->handle, $start);
$data = fread($this->handle, $length);
@@ -579,12 +531,8 @@ class GifFrameExtractor
/**
* Check if a character if a byte (old: checkbyte)
*
* @param integer $byte
*
* @return boolean
*/
private function checkByte($byte)
private function checkByte(int $byte): bool
{
if (fgetc($this->handle) == chr($byte)) {
fseek($this->handle, $this->pointer);
@@ -598,10 +546,8 @@ class GifFrameExtractor
/**
* Check the end of the file (old: checkEOF)
*
* @return boolean
*/
private function checkEOF()
private function checkEOF(): bool
{
if (fgetc($this->handle) === false) {
return true;
@@ -628,70 +574,56 @@ class GifFrameExtractor
/**
* Get the total of all added frame duration
*
* @return integer
*/
public function getTotalDuration()
public function getTotalDuration(): int
{
return $this->totalDuration;
}
/**
* Get the number of extracted frames
*
* @return integer
*/
public function getFrameNumber()
public function getFrameNumber(): int
{
return $this->frameNumber;
}
/**
* Get the extracted frames (images and durations)
*
* @return array
*/
public function getFrames()
public function getFrames(): array
{
return $this->frames;
}
/**
* Get the extracted frame positions
*
* @return array
*/
public function getFramePositions()
public function getFramePositions(): array
{
return $this->framePositions;
}
/**
* Get the extracted frame dimensions
*
* @return array
*/
public function getFrameDimensions()
public function getFrameDimensions(): array
{
return $this->frameDimensions;
}
/**
* Get the extracted frame images
*
* @return array
*/
public function getFrameImages()
public function getFrameImages(): array
{
return $this->frameImages;
}
/**
* Get the extracted frame durations
*
* @return array
*/
public function getFrameDurations()
public function getFrameDurations(): array
{
return $this->frameDurations;
}

View File

@@ -8,10 +8,8 @@ trait Uuids
{
/**
* Boot function from Laravel.
*
* @return void
*/
protected static function bootUuids()
protected static function bootUuids(): void
{
static::creating(function ($model) {
if (empty($model->{$model->getKeyName()}) === true) {
@@ -22,20 +20,16 @@ trait Uuids
/**
* Get the value indicating whether the IDs are incrementing.
*
* @return boolean
*/
public function getIncrementing()
public function getIncrementing(): bool
{
return false;
}
/**
* Get the auto-incrementing key type.
*
* @return string
*/
public function getKeyType()
public function getKeyType(): string
{
return 'string';
}

View File

@@ -8,15 +8,15 @@
],
"license": "MIT",
"require": {
"php": "^8.0.2",
"php": "^8.1",
"doctrine/dbal": "^3.5",
"guzzlehttp/guzzle": "^7.2",
"intervention/image": "^2.7",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7",
"laravel/framework": "^10.12",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"league/flysystem-aws-s3-v3": "^3.12",
"owen-it/laravel-auditing": "^13.0",
"owen-it/laravel-auditing": "^13.1",
"php-ffmpeg/php-ffmpeg": "^1.1",
"sunspikes/clamav-validator": "*",
"thiagoalessio/tesseract_ocr": "^2.12",
@@ -25,11 +25,11 @@
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.1",
"phpunit/phpunit": "^10.1.3",
"spatie/laravel-ignition": "^1.0"
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"files": [
@@ -77,6 +77,6 @@
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true
}

View File

@@ -1,5 +1,6 @@
<?php
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Facade;
return [
@@ -154,34 +155,7 @@ return [
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
'providers' => ServiceProvider::defaultProviders()->merge([
/*
* Package Service Providers...
*/
@@ -196,8 +170,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
])->toArray(),
/*
|--------------------------------------------------------------------------

View File

@@ -80,16 +80,20 @@ return [
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],

View File

@@ -36,7 +36,7 @@ return [
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST') === true ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,

View File

@@ -58,9 +58,8 @@ return [
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') === true ? array_filter([
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::ATTR_TIMEOUT => env('DB_TIMEOUT', 30),
]) : [],
],

View File

@@ -29,11 +29,13 @@ return [
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . "/storage",
'public' => true,
'throw' => false,
],
'cdn' => [
@@ -68,6 +70,26 @@ return [
]
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*

View File

@@ -3,6 +3,7 @@
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
@@ -61,6 +62,7 @@ return [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
@@ -68,6 +70,7 @@ return [
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
'replace_placeholders' => true,
],
'slack' => [
@@ -76,6 +79,7 @@ return [
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
@@ -87,6 +91,7 @@ return [
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
@@ -97,16 +102,20 @@ return [
'with' => [
'stream' => 'php://stderr',
],
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => LOG_USER,
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [

View File

@@ -28,7 +28,7 @@ return [
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "log", "array", "failover"
|
*/
@@ -51,10 +51,16 @@ return [
'mailgun' => [
'transport' => 'mailgun',
// 'client' => [
// 'timeout' => 5,
// ],
],
'postmark' => [
'transport' => 'postmark',
// 'client' => [
// 'timeout' => 5,
// ],
],
'sendmail' => [

View File

@@ -36,4 +36,5 @@ return [
'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_SITE_KEY'),
],
];

View File

@@ -15,7 +15,7 @@ class ArticleFactory extends Factory
*
* @return array<string, mixed>
*/
public function definition()
public function definition(): array
{
$publishDate = Carbon::parse($this->faker->dateTimeBetween('-1 month', '+1 month'));
@@ -24,8 +24,8 @@ class ArticleFactory extends Factory
'slug' => $this->faker->slug(),
'publish_at' => $publishDate,
'content' => $this->faker->paragraphs(3, true),
'user_id' => $this->faker->uuid,
'hero' => $this->faker->uuid,
'user_id' => $this->faker->uuid(),
'hero' => $this->faker->uuid(),
];
}
}

View File

@@ -15,7 +15,7 @@ class EventFactory extends Factory
*
* @return array<string, mixed>
*/
public function definition()
public function definition(): array
{
$startDate = Carbon::parse($this->faker->dateTimeBetween('now', '+1 year'));
$endDate = Carbon::parse($this->faker->dateTimeBetween($startDate, '+1 year'));
@@ -24,14 +24,14 @@ class EventFactory extends Factory
return [
'title' => $this->faker->sentence(),
'location' => $this->faker->randomElement(['online', 'physical']),
'address' => $this->faker->address,
'address' => $this->faker->address(),
'start_at' => $startDate,
'end_at' => $endDate,
'publish_at' => $publishDate,
'status' => $this->faker->randomElement(['draft', 'soon', 'open', 'closed', 'cancelled']),
'registration_type' => $this->faker->randomElement(['none', 'email', 'link', 'message']),
'registration_data' => $this->faker->sentence(),
'hero' => $this->faker->uuid,
'hero' => $this->faker->uuid(),
'content' => $this->faker->paragraphs(3, true),
'price' => $this->faker->numberBetween(0, 150),
'ages' => $this->faker->regexify('\d+(\+|\-\d+)?'),

View File

@@ -15,13 +15,13 @@ class MediaFactory extends Factory
*
* @return array<string, mixed>
*/
public function definition()
public function definition(): array
{
return [
'title' => $this->faker->sentence(),
'name' => storage_path('app/public/') . $this->faker->slug() . '.' . $this->faker->fileExtension,
'mime_type' => $this->faker->mimeType,
'user_id' => $this->faker->uuid,
'name' => storage_path('app/public/') . $this->faker->slug() . '.' . $this->faker->fileExtension(),
'mime_type' => $this->faker->mimeType(),
'user_id' => $this->faker->uuid(),
'size' => $this->faker->numberBetween(1000, 1000000),
];
}

View File

@@ -15,7 +15,7 @@ class UserFactory extends Factory
*
* @return array<string, mixed>
*/
public function definition()
public function definition(): array
{
$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker));
@@ -39,10 +39,8 @@ class UserFactory extends Factory
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified()
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -30,10 +28,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('users');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
@@ -22,10 +20,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('password_resets');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
@@ -26,10 +24,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
@@ -27,10 +25,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -27,10 +25,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('posts');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('media', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -27,10 +25,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('media');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('permissions', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -25,10 +23,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('permissions');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('events', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -32,10 +30,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('events');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -23,10 +21,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('subscriptions');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
@@ -26,10 +24,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('jobs');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('user_codes', function (Blueprint $table) {
$table->id();
@@ -27,10 +25,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('user_codes');
}

View File

@@ -5,14 +5,12 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
class CreateAuditsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->create('audits', function (Blueprint $table) {
@@ -37,11 +35,9 @@ class CreateAuditsTable extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->drop('audits');
}
}
};

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('user_logins', function (Blueprint $table) {
$table->uuid('id')->primary();
@@ -29,10 +27,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('user_logins');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('analytics', function (Blueprint $table) {
$table->id();
@@ -25,10 +23,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('analytics');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('attachments', function (Blueprint $table) {
$table->id();
@@ -25,10 +23,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('attachments');
}

View File

@@ -8,10 +8,8 @@ return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
$table->string('price')->default("");
@@ -20,10 +18,8 @@ return new class extends Migration
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('price');

Some files were not shown because too many files have changed in this diff Show More