diff --git a/composer.json b/composer.json index 4345b3b..e2639d2 100755 --- a/composer.json +++ b/composer.json @@ -9,11 +9,11 @@ } }, "require": { - "eveseat/web": "^4.0", - "eveseat/eveapi": "^4.0", - "eveseat/notifications": "^4.0", - "eveseat/services": "^4.0", - "eveseat/eseye": "^2.1", + "eveseat/web": "^5.0", + "eveseat/eveapi": "^5.0", + "eveseat/notifications": "^5.0", + "eveseat/services": "^5.0", + "eveseat/eseye": "^3.0", "s9e/text-formatter": "^2.4" }, "authors": [{ @@ -24,7 +24,7 @@ "email": "loic.leuilliot@gmail.com" }], "license": "GPL-3.0-or-later", - "minimum-stability": "alpha", + "minimum-stability": "dev", "prefer-stable": true, "extra": { "laravel": { @@ -32,5 +32,9 @@ "Seat\\Kassie\\Calendar\\CalendarServiceProvider" ] } + }, + "require-dev": { + "rector/rector": "^0.18.3", + "driftingly/rector-laravel": "^0.24.1" } } diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..4188fdd --- /dev/null +++ b/rector.php @@ -0,0 +1,26 @@ +paths([ + __DIR__ . '/src', + ]); + + // register a single rule + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + // define sets of rules + $rectorConfig->sets(sets: [ + LevelSetList::UP_TO_PHP_82, + SetList::CODE_QUALITY, + SetList::TYPE_DECLARATION, + LaravelSetList::LARAVEL_100 + ]); +}; diff --git a/src/CalendarServiceProvider.php b/src/CalendarServiceProvider.php index 99e70c9..bb08d3f 100755 --- a/src/CalendarServiceProvider.php +++ b/src/CalendarServiceProvider.php @@ -14,7 +14,7 @@ */ class CalendarServiceProvider extends AbstractSeatPlugin { - public function boot() + public function boot(): void { $this->addCommands(); $this->addRoutes(); @@ -24,13 +24,13 @@ public function boot() $this->addPublications(); $this->addObservers(); - $this->app->booted(function () { + $this->app->booted(function (): void { $schedule = $this->app->make(Schedule::class); $schedule->command('calendar:remind')->everyMinute(); }); } - public function register() + public function register(): void { $this->mergeConfigFrom(__DIR__ . '/Config/package.sidebar.php', 'package.sidebar'); $this->mergeConfigFrom(__DIR__ . '/Config/calendar.character.menu.php', 'package.character.menu'); @@ -41,27 +41,27 @@ public function register() $this->registerPermissions(__DIR__ . '/Config/Permissions/corporation.php', 'corporation'); } - private function addRoutes() + private function addRoutes(): void { $this->loadRoutesFrom(__DIR__ . '/Http/routes.php'); } - private function addViews() + private function addViews(): void { $this->loadViewsFrom(__DIR__ . '/resources/views', 'calendar'); } - private function addTranslations() + private function addTranslations(): void { $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'calendar'); } - private function addMigrations() + private function addMigrations(): void { $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); } - private function addPublications() + private function addPublications(): void { $this->publishes([ __DIR__ . '/resources/assets/css' => public_path('web/css'), @@ -71,12 +71,12 @@ private function addPublications() ]); } - private function addObservers() + private function addObservers(): void { Operation::observe(OperationObserver::class); } - private function addCommands() + private function addCommands(): void { $this->commands([ RemindOperation::class, diff --git a/src/Commands/RemindOperation.php b/src/Commands/RemindOperation.php index b9bed8c..233da50 100755 --- a/src/Commands/RemindOperation.php +++ b/src/Commands/RemindOperation.php @@ -28,14 +28,14 @@ class RemindOperation extends Command /** * Process the command. */ - public function handle() + public function handle(): void { # Ensure we send reminders starting with furthest in the future. That way # when more than one event is being reminded, the last reminder in chat # is the next event to occur. $configured_marks = setting('kassie.calendar.notify_operation_interval', true); if ($configured_marks === null || !setting('kassie.calendar.slack_integration', true)) return; - $marks = explode(',', $configured_marks); + $marks = explode(',', (string) $configured_marks); rsort($marks); foreach ($marks as $mark) diff --git a/src/Helpers/Helper.php b/src/Helpers/Helper.php index 2d0e9e0..eec6226 100755 --- a/src/Helpers/Helper.php +++ b/src/Helpers/Helper.php @@ -16,10 +16,10 @@ class Helper * @param $emoji_empty * @return string */ - public static function ImportanceAsEmoji($importance, $emoji_full, $emoji_half, $emoji_empty) { + public static function ImportanceAsEmoji($importance, string $emoji_full, string $emoji_half, string $emoji_empty): string { $output = ""; - $tmp = explode('.', $importance); + $tmp = explode('.', (string) $importance); $val = $tmp[0]; $dec = 0; @@ -48,11 +48,10 @@ public static function ImportanceAsEmoji($importance, $emoji_full, $emoji_half, public static function BuildSlackNotificationAttachment($op) { $url = url('/calendar/operation', [$op->id]); - $fields = array(); + $fields = []; $fields[trans('calendar::seat.starts_at')] = $op->start_at->format('F j @ H:i EVE'); - $fields[trans('calendar::seat.duration')] = $op->getDurationAttribute() ? - $op->getDurationAttribute() : trans('calendar::seat.unknown'); + $fields[trans('calendar::seat.duration')] = $op->getDurationAttribute() ?: trans('calendar::seat.unknown'); $fields[trans('calendar::seat.importance')] = self::ImportanceAsEmoji( @@ -61,12 +60,12 @@ public static function BuildSlackNotificationAttachment($op) { setting('kassie.calendar.slack_emoji_importance_half', true), setting('kassie.calendar.slack_emoji_importance_empty', true)); - $fields[trans('calendar::seat.fleet_commander')] = $op->fc ? $op->fc : trans('calendar::seat.unknown'); - $fields[trans('calendar::seat.staging_system')] = $op->staging_sys ? $op->staging_sys : trans('calendar::seat.unknown'); - $fields[trans('calendar::seat.staging_info')] = $op->staging_info ? $op->staging_info : trans('calendar::seat.unknown'); - $fields[trans('calendar::seat.description')] = $op->description ? $op->description : trans('calendar::seat.unknown'); + $fields[trans('calendar::seat.fleet_commander')] = $op->fc ?: trans('calendar::seat.unknown'); + $fields[trans('calendar::seat.staging_system')] = $op->staging_sys ?: trans('calendar::seat.unknown'); + $fields[trans('calendar::seat.staging_info')] = $op->staging_info ?: trans('calendar::seat.unknown'); + $fields[trans('calendar::seat.description')] = $op->description ?: trans('calendar::seat.unknown'); - return function ($attachment) use ($op, $url, $fields) { + return function ($attachment) use ($op, $url, $fields): void { $attachment->title($op->title, $url) ->fields($fields) ->footer(trans('calendar::seat.created_by') . ' ' . $op->user->name) diff --git a/src/Http/Controllers/AjaxController.php b/src/Http/Controllers/AjaxController.php index e7fe63a..289cdf8 100644 --- a/src/Http/Controllers/AjaxController.php +++ b/src/Http/Controllers/AjaxController.php @@ -23,11 +23,11 @@ public function getOngoing() { $operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging') ->where('start_at', '<', carbon()->now()) - ->where(function ($query) { + ->where(function ($query): void { $query->where('end_at', '>', carbon()->now()); $query->orWhereNull('end_at'); }) - ->where(function ($query) { + ->where(function ($query): void { if (! auth()->user()->isAdmin()) { $query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray()); $query->orWhereNull('role_name'); @@ -44,7 +44,7 @@ public function getOngoing() public function getIncoming() { $operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging') - ->where(function ($query) { + ->where(function ($query): void { if (! auth()->user()->isAdmin()) { $query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray()); $query->orWhereNull('role_name'); @@ -62,11 +62,11 @@ public function getIncoming() public function getFaded() { $operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging') - ->where(function ($query) { + ->where(function ($query): void { $query->where('start_at', '<', carbon()->now()) ->where('end_at', '<', carbon()->now()); }) - ->where(function ($query) { + ->where(function ($query): void { if (! auth()->user()->isAdmin()) { $query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray()); $query->orWhereNull('role_name'); @@ -85,7 +85,7 @@ public function getDetail($operation_id) { if (auth()->user()->can('calendar.view')) { $op = Operation::with('tags')->find($operation_id); - return view('calendar::operation.modals/details.content', compact('op')); + return view('calendar::operation.modals/details.content', ['op' => $op]); } return redirect() @@ -94,25 +94,16 @@ public function getDetail($operation_id) } /** - * @param Builder $operations * @return mixed */ private function buildOperationDataTable(Builder $operations) { return app('datatables')::of($operations) - ->editColumn('title', function ($row) { - return view('calendar::operation.partials.title', compact('row')); - }) - ->editColumn('tags', function ($row) { - return view('calendar::operation.partials.tags', ['op' => $row]); - }) - ->editColumn('importance', function ($row) { - return view('calendar::operation.partials.importance', ['op' => $row]); - }) - ->editColumn('start_at', function ($row) { - return sprintf('%s', - $row->start_at, human_diff($row->start_at)); - }) + ->editColumn('title', fn($row) => view('calendar::operation.partials.title', ['row' => $row])) + ->editColumn('tags', fn($row) => view('calendar::operation.partials.tags', ['op' => $row])) + ->editColumn('importance', fn($row) => view('calendar::operation.partials.importance', ['op' => $row])) + ->editColumn('start_at', fn($row): string => sprintf('%s', + $row->start_at, human_diff($row->start_at))) ->editColumn('end_at', function ($row) { if ($row->end_at) { return sprintf('%s', @@ -121,30 +112,16 @@ private function buildOperationDataTable(Builder $operations) return ''; } }) - ->editColumn('fleet_commander', function ($row) { - return view('calendar::operation.partials.fleet_commander', ['op' => $row]); - }) - ->addColumn('duration', function ($row) { - return sprintf('%s', - $row->end_at, $row->duration); - }) - ->editColumn('staging_sys', function ($row) { - return view('calendar::operation.partials.staging', ['op' => $row]); - }) - ->addColumn('subscription', function ($row) { - return view('calendar::operation.partials.registration', ['op' => $row]); - }) - ->addColumn('actions', function ($row) { - return view('calendar::operation.partials.actions.actions', ['op' => $row]); - }) - ->setRowClass(function ($row) { - return $row->is_cancelled == 0 ? 'text-muted' : 'danger text-muted'; - }) - ->addRowAttr('data-attr-op', function ($row) { - return $row->id; - }) + ->editColumn('fleet_commander', fn($row) => view('calendar::operation.partials.fleet_commander', ['op' => $row])) + ->addColumn('duration', fn($row): string => sprintf('%s', + $row->end_at, $row->duration)) + ->editColumn('staging_sys', fn($row) => view('calendar::operation.partials.staging', ['op' => $row])) + ->addColumn('subscription', fn($row) => view('calendar::operation.partials.registration', ['op' => $row])) + ->addColumn('actions', fn($row) => view('calendar::operation.partials.actions.actions', ['op' => $row])) + ->setRowClass(fn($row): string => $row->is_cancelled == 0 ? 'text-muted' : 'danger text-muted') + ->addRowAttr('data-attr-op', fn($row) => $row->id) ->rawColumns(['title', 'tags', 'importance', 'start_at', 'end_at', 'duration', 'fleet_commander', 'staging_sys', 'subscription', 'actions']) - ->make(true); + ->toJson(); } } diff --git a/src/Http/Controllers/CharacterController.php b/src/Http/Controllers/CharacterController.php index 1f61b4b..1c2e042 100644 --- a/src/Http/Controllers/CharacterController.php +++ b/src/Http/Controllers/CharacterController.php @@ -21,8 +21,6 @@ class CharacterController extends Controller { /** - * @param \Seat\Eveapi\Models\Character\CharacterInfo $character - * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function paps(CharacterInfo $character) @@ -37,7 +35,7 @@ public function paps(CharacterInfo $character) $shipTypePaps = InvType::rightJoin('invGroups', 'invGroups.groupID', '=', 'invTypes.groupID') ->leftJoin('kassie_calendar_paps', 'ship_type_id', '=', 'typeID') ->where('categoryID', 6) - ->where(function($query) use ($character) { + ->where(function($query) use ($character): void { $query->where('character_id', $character->character_id) ->orWhere('character_id', null); }) @@ -67,7 +65,6 @@ public function paps(CharacterInfo $character) ->orderBy('qty', 'desc') ->get(); - return view('calendar::character.paps', compact('monthlyPaps', 'shipTypePaps', - 'weeklyRanking', 'monthlyRanking', 'yearlyRanking', 'character')); + return view('calendar::character.paps', ['monthlyPaps' => $monthlyPaps, 'shipTypePaps' => $shipTypePaps, 'weeklyRanking' => $weeklyRanking, 'monthlyRanking' => $monthlyRanking, 'yearlyRanking' => $yearlyRanking, 'character' => $character]); } } diff --git a/src/Http/Controllers/CorporationController.php b/src/Http/Controllers/CorporationController.php index 2f19c5c..17257e9 100644 --- a/src/Http/Controllers/CorporationController.php +++ b/src/Http/Controllers/CorporationController.php @@ -20,8 +20,6 @@ class CorporationController extends Controller { /** - * @param \Seat\Eveapi\Models\Corporation\CorporationInfo $corporation - * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function getPaps(CorporationInfo $corporation) @@ -29,7 +27,7 @@ public function getPaps(CorporationInfo $corporation) $today = carbon(); $weeklyRanking = Pap::with('character', 'character.affiliation') - ->whereHas('character.affiliation', function ($query) use ($corporation) { + ->whereHas('character.affiliation', function ($query) use ($corporation): void { $query->where('corporation_id', $corporation->corporation_id); }) ->where('week', $today->weekOfMonth) @@ -42,7 +40,7 @@ public function getPaps(CorporationInfo $corporation) ->get(); $monthlyRanking = Pap::with('character', 'character.affiliation') - ->whereHas('character.affiliation', function ($query) use ($corporation) { + ->whereHas('character.affiliation', function ($query) use ($corporation): void { $query->where('corporation_id', $corporation->corporation_id); }) ->where('month', $today->month) @@ -54,7 +52,7 @@ public function getPaps(CorporationInfo $corporation) ->get(); $yearlyRanking = Pap::with('character', 'character.affiliation') - ->whereHas('character.affiliation', function ($query) use ($corporation) { + ->whereHas('character.affiliation', function ($query) use ($corporation): void { $query->where('corporation_id', $corporation->corporation_id); }) ->where('year', $today->year) @@ -64,11 +62,10 @@ public function getPaps(CorporationInfo $corporation) ->orderBy('qty', 'desc') ->get(); - return view('calendar::corporation.paps', compact('weeklyRanking', 'monthlyRanking', 'yearlyRanking', 'corporation')); + return view('calendar::corporation.paps', ['weeklyRanking' => $weeklyRanking, 'monthlyRanking' => $monthlyRanking, 'yearlyRanking' => $yearlyRanking, 'corporation' => $corporation]); } /** - * @param int $corporation_id * @return \Illuminate\Http\JsonResponse */ public function getYearPapsStats(int $corporation_id) @@ -85,38 +82,36 @@ public function getYearPapsStats(int $corporation_id) if (! $grouped) return response()->json( Pap::with('character', 'character.affiliation') - ->whereHas('character.affiliation', function ($query) use ($corporation_id) { + ->whereHas('character.affiliation', function ($query) use ($corporation_id): void { $query->where('corporation_id', $corporation_id); }) - ->where('year', intval($year)) + ->where('year', (int) $year) ->select('character_id') ->selectRaw('SUM(value) as qty') ->groupBy('character_id') ->orderBy('qty', 'desc') ->get() - ->map(function ($pap) { - return [ - 'character_id' => $pap->character_id, - 'name' => $pap->character->name, - 'qty' => $pap->qty, - ]; - }) + ->map(fn($pap): array => [ + 'character_id' => $pap->character_id, + 'name' => $pap->character->name, + 'qty' => $pap->qty, + ]) ->sortBy('name') ->values()); return response()->json( Pap::with('character', 'character.affiliation', 'character.user') - ->whereHas('character.affiliation', function ($query) use ($corporation_id) { + ->whereHas('character.affiliation', function ($query) use ($corporation_id): void { $query->where('corporation_id', $corporation_id); }) - ->where('year', intval($year)) + ->where('year', (int) $year) ->select('character_id') ->selectRaw(DB::raw('SUM(value) as qty')) ->groupBy('character_id') ->orderBy('qty', 'desc') ->get() ->groupBy('character.user.id') - ->map(function ($user) { + ->map(function ($user): array { $pap = [ 'character_id' => 0, 'name' => trans('web::seat.unknown'), @@ -136,13 +131,12 @@ public function getYearPapsStats(int $corporation_id) } /** - * @param int $corporation_id * @return \Illuminate\Http\JsonResponse */ public function getMonthlyStackedPapsStats(int $corporation_id) { - $year = is_null(request()->query('year')) ? carbon()->year : intval(request()->query('year')); - $month = is_null(request()->query('month')) ? carbon()->month : intval(request()->query('month')); + $year = is_null(request()->query('year')) ? carbon()->year : (int) request()->query('year'); + $month = is_null(request()->query('month')) ? carbon()->month : (int) request()->query('month'); $grouped = request()->query('grouped') ?: false; $paps = Pap::select('ci.character_id', 'cto.operation_id', 'analytics', 'value') diff --git a/src/Http/Controllers/LookupController.php b/src/Http/Controllers/LookupController.php index a34e623..2447b18 100755 --- a/src/Http/Controllers/LookupController.php +++ b/src/Http/Controllers/LookupController.php @@ -17,7 +17,6 @@ class LookupController extends Controller { /** - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function lookupCharacters(Request $request) @@ -27,20 +26,16 @@ public function lookupCharacters(Request $request) ->get() ->unique('character_id'); - $results = array(); + $results = []; foreach ($characters as $character) { - array_push($results, array( - "value" => $character->name, - "data" => $character->character_id - )); + $results[] = ["value" => $character->name, "data" => $character->character_id]; } - return response()->json(array('suggestions' => $results)); + return response()->json(['suggestions' => $results]); } /** - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function lookupSystems(Request $request) @@ -50,20 +45,16 @@ public function lookupSystems(Request $request) ['itemName', 'like', $request->input('query') . '%'] ])->take(10)->get(); - $results = array(); + $results = []; foreach ($systems as $system) { - array_push($results, array( - "value" => $system->itemName, - "data" => $system->itemID - )); + $results[] = ["value" => $system->itemName, "data" => $system->itemID]; } - return response()->json(array('suggestions' => $results)); + return response()->json(['suggestions' => $results]); } /** - * @param \Illuminate\Http\Request $request * @return mixed */ public function lookupAttendees(Request $request) @@ -75,24 +66,15 @@ public function lookupAttendees(Request $request) return app('DataTables')::collection($attendees) ->removeColumn('character_id', 'main_character', 'user_id', 'status', 'character', 'created_at', 'updated_at') - ->addColumn('_character', function ($row) { - return view('web::partials.character', ['character' => $row->character]); - }) - ->addColumn('_character_name', function ($row) { - return is_null($row->character) ? '' : $row->character->name; - }) - ->addColumn('_status', function ($row) { - return view('calendar::operation.includes.cols.attendees.status', compact('row')); - }) - ->addColumn('_timestamps', function ($row) { - return view('calendar::operation.includes.cols.attendees.timestamps', compact('row')); - }) + ->addColumn('_character', fn($row) => view('web::partials.character', ['character' => $row->character])) + ->addColumn('_character_name', fn($row) => is_null($row->character) ? '' : $row->character->name) + ->addColumn('_status', fn($row) => view('calendar::operation.includes.cols.attendees.status', ['row' => $row])) + ->addColumn('_timestamps', fn($row) => view('calendar::operation.includes.cols.attendees.timestamps', ['row' => $row])) ->rawColumns(['_character', '_status', '_timestamps']) - ->make(true); + ->toJson(); } /** - * @param \Illuminate\Http\Request $request * @return mixed */ public function lookupConfirmed(Request $request) @@ -110,15 +92,9 @@ public function lookupConfirmed(Request $request) return app('DataTables')::collection($confirmed) ->removeColumn('ship_type_id', 'character_id') - ->editColumn('character.character_id', function ($row) { - return view('web::partials.character', ['character' => $row->character]); - }) - ->editColumn('character.corporation_id', function ($row) { - return view('web::partials.corporation', ['corporation' => $row->character->affiliation->corporation]); - }) - ->editColumn('type.typeID', function ($row) { - return view('web::partials.type', ['type_id' => $row->type->typeID, 'type_name' => $row->type->typeName]); - }) - ->make(true); + ->editColumn('character.character_id', fn($row) => view('web::partials.character', ['character' => $row->character])) + ->editColumn('character.corporation_id', fn($row) => view('web::partials.corporation', ['corporation' => $row->character->affiliation->corporation])) + ->editColumn('type.typeID', fn($row) => view('web::partials.type', ['type_id' => $row->type->typeID, 'type_name' => $row->type->typeName])) + ->toJson(); } } diff --git a/src/Http/Controllers/OperationController.php b/src/Http/Controllers/OperationController.php index a68fee1..89750f0 100755 --- a/src/Http/Controllers/OperationController.php +++ b/src/Http/Controllers/OperationController.php @@ -6,11 +6,13 @@ use Illuminate\Http\Request; use Carbon\Carbon; use Seat\Eseye\Containers\EsiAuthentication; +use Seat\Eseye\Eseye; use Seat\Eseye\Exceptions\EsiScopeAccessDeniedException; use Seat\Eseye\Exceptions\RequestFailedException; use Seat\Eveapi\Models\RefreshToken; use Seat\Kassie\Calendar\Models\Pap; use Seat\Notifications\Models\Integration; +use Seat\Services\Contracts\EsiClient; use Seat\Web\Http\Controllers\Controller; use Seat\Kassie\Calendar\Models\Operation; use Seat\Kassie\Calendar\Models\Attendee; @@ -32,7 +34,6 @@ public function __construct() { } /** - * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \Seat\Services\Exceptions\SettingException */ @@ -48,25 +49,20 @@ public function index(Request $request) if ($main_character != null) { $main_character->main = true; - $user_characters = $user_characters->reject(function ($character) use ($main_character) { - return $character->character_id == $main_character->character_id; - }); + $user_characters = $user_characters->reject(fn($character): bool => $character->character_id == $main_character->character_id); $user_characters->prepend($main_character); } return view('calendar::operation.index', [ 'roles' => $roles, 'characters' => $user_characters, - 'default_op' => $request->id ? $request->id : 0, + 'default_op' => $request->id ?: 0, 'tags' => $tags, 'notification_channels' => $notification_channels, ]); } - /** - * @param Request $request - */ - public function store(Request $request) + public function store(Request $request): void { $this->validate($request, [ 'title' => 'required', @@ -77,12 +73,12 @@ public function store(Request $request) ]); $operation = new Operation($request->all()); - $tags = array(); + $tags = []; foreach ($request->toArray() as $name => $value) { - if (empty($value)) + if (empty($value)) { $operation->{$name} = null; - else if (strpos($name, 'checkbox-') !== false) { + } elseif (str_contains($name, 'checkbox-')) { $tags[] = $value; } } @@ -90,7 +86,7 @@ public function store(Request $request) if ($request->known_duration == "no") $operation->start_at = Carbon::parse($request->time_start); else { - $dates = explode(" - ", $request->time_start_end); + $dates = explode(" - ", (string) $request->time_start_end); $operation->start_at = Carbon::parse($dates[0]); $operation->end_at = Carbon::parse($dates[1]); } @@ -110,7 +106,6 @@ public function store(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request) @@ -124,15 +119,16 @@ public function update(Request $request) ]); $operation = Operation::find($request->operation_id); - $tags = array(); + $tags = []; if (auth()->user()->can('calendar.update_all') || $operation->user->id == auth()->user()->id) { foreach ($request->toArray() as $name => $value) { - if (empty($value)) + if (empty($value)) { $operation->{$name} = null; - else if (strpos($name, 'checkbox-') !== false) + } elseif (str_contains($name, 'checkbox-')) { $tags[] = $value; + } } $operation->title = $request->title; @@ -149,7 +145,7 @@ public function update(Request $request) $operation->start_at = Carbon::parse($request->time_start); $operation->end_at = null; } else { - $dates = explode(" - ", $request->time_start_end); + $dates = explode(" - ", (string) $request->time_start_end); $operation->start_at = Carbon::parse($dates[0]); $operation->end_at = Carbon::parse($dates[1]); } @@ -175,21 +171,16 @@ public function update(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function delete(Request $request) { $operation = Operation::find($request->operation_id); - if (auth()->user()->can('calendar.delete_all') || $operation->user->id == auth()->user()->id) { - if ($operation != null) { - - if (! $operation->isUserGranted(auth()->user())) - return redirect()->back()->with('error', 'You are not granted to this operation !'); - - Operation::destroy($operation->id); - return redirect()->route('operation.index'); - } + if ((auth()->user()->can('calendar.delete_all') || $operation->user->id == auth()->user()->id) && $operation != null) { + if (! $operation->isUserGranted(auth()->user())) + return redirect()->back()->with('error', 'You are not granted to this operation !'); + Operation::destroy($operation->id); + return redirect()->route('operation.index'); } return redirect() @@ -198,19 +189,15 @@ public function delete(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function close(Request $request) { $operation = Operation::find($request->operation_id); - if (auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) { - - if ($operation != null) { - $operation->end_at = Carbon::now('UTC'); - $operation->save(); - return redirect()->route('operation.index'); - } + if ((auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) && $operation != null) { + $operation->end_at = Carbon::now('UTC'); + $operation->save(); + return redirect()->route('operation.index'); } return redirect() @@ -219,23 +206,18 @@ public function close(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function cancel(Request $request) { $operation = Operation::find($request->operation_id); - if (auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) { - if ($operation != null) { - - $operation->timestamps = false; - $operation->is_cancelled = true; - $operation->integration_id = ($request->get('integration_id') == "") ? - null : $request->get('integration_id'); - $operation->save(); - - return redirect()->route('operation.index'); - } + if ((auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) && $operation != null) { + $operation->timestamps = false; + $operation->is_cancelled = true; + $operation->integration_id = ($request->get('integration_id') == "") ? + null : $request->get('integration_id'); + $operation->save(); + return redirect()->route('operation.index'); } return redirect() @@ -244,22 +226,18 @@ public function cancel(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function activate(Request $request) { $operation = Operation::find($request->operation_id); - if (auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) { - if ($operation != null) { - $operation->timestamps = false; - $operation->is_cancelled = false; - $operation->integration_id = ($request->get('integration_id') == "") ? - null : $request->get('integration_id'); - $operation->save(); - - return redirect()->route('operation.index'); - } + if ((auth()->user()->can('calendar.close_all') || $operation->user->id == auth()->user()->id) && $operation != null) { + $operation->timestamps = false; + $operation->is_cancelled = false; + $operation->integration_id = ($request->get('integration_id') == "") ? + null : $request->get('integration_id'); + $operation->save(); + return redirect()->route('operation.index'); } return redirect() @@ -268,7 +246,6 @@ public function activate(Request $request) } /** - * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function subscribe(Request $request) @@ -321,7 +298,6 @@ public function find($operation_id) { } /** - * @param int $operation_id * @return \Illuminate\Http\RedirectResponse * @throws \Seat\Eseye\Exceptions\InvalidContainerDataException */ @@ -361,11 +337,11 @@ public function paps(int $operation_id) 'character_id' => $token->character_id, ]); - $members = $client->setVersion('v1')->invoke('get', '/fleets/{fleet_id}/members/', [ - 'fleet_id' => $fleet->fleet_id, + $membersResponse = $client->setVersion('v1')->invoke('get', '/fleets/{fleet_id}/members/', [ + 'fleet_id' => $fleet->getBody()->fleet_id, ]); - foreach ($members as $member) { + foreach ($membersResponse->getBody() as $member) { Pap::firstOrCreate([ 'character_id' => $member->character_id, 'operation_id' => $operation_id, @@ -375,9 +351,6 @@ public function paps(int $operation_id) ]); } } catch (RequestFailedException $e) { - - $this->updateToken($token, $client->getAuthentication()); - if ($e->getError() == 'Character is not in a fleet') return redirect() ->back() @@ -391,53 +364,26 @@ public function paps(int $operation_id) return redirect() ->back() ->with('error', 'Esi respond with an unhandled error : (' . $e->getCode() . ') ' . $e->getError()); - } catch (EsiScopeAccessDeniedException $e) { - - $this->updateToken($token, $client->getAuthentication()); - + } catch (EsiScopeAccessDeniedException) { return redirect() ->back() - ->with('error', 'Registered tokens has not enough privileges. '. - 'Please bind your character and pap again.'); + ->with('error', 'Registered tokens has not enough privileges. Please bind your character and pap again.'); } - $this->updateToken($token, $client->getAuthentication()); - return redirect() ->back() ->with('success', 'Fleet members has been successfully papped.'); } /** - * @param RefreshToken $token - * @return mixed + * @return EsiClient * @throws \Seat\Eseye\Exceptions\InvalidContainerDataException */ private function eseye(RefreshToken $token) { - $client = app('esi-client'); - - return $client = $client->get(new EsiAuthentication([ - 'refresh_token' => $token->refresh_token, - 'access_token' => $token->token, - 'token_expires' => $token->expires_on, - 'scopes' => $token->scopes, - ])); - } + $client = app()->make(EsiClient::class); + $client->setAuthentication($token); - /** - * @param RefreshToken $token - * @param EsiAuthentication $last_auth - */ - private function updateToken(RefreshToken $token, EsiAuthentication $last_auth) - { - if (! empty($last_auth->refresh_token)) - $token->refresh_token = $last_auth->refresh_token; - - $token->token = $last_auth->access_token ?? '-'; - $token->expires_on = $last_auth->token_expires; - - $token->save(); + return $client; } - } diff --git a/src/Http/Controllers/TagController.php b/src/Http/Controllers/TagController.php index ea017e5..ce793e3 100755 --- a/src/Http/Controllers/TagController.php +++ b/src/Http/Controllers/TagController.php @@ -14,7 +14,6 @@ class TagController extends Controller { /** - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Validation\ValidationException */ @@ -51,7 +50,6 @@ public function store(Request $request) } /** - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function delete(Request $request) @@ -66,7 +64,6 @@ public function delete(Request $request) } /** - * @param int $tag_id * @return \Illuminate\Http\JsonResponse */ public function get(int $tag_id) diff --git a/src/Http/Validation/SettingsValidation.php b/src/Http/Validation/SettingsValidation.php index e0e03e6..61e6df8 100644 --- a/src/Http/Validation/SettingsValidation.php +++ b/src/Http/Validation/SettingsValidation.php @@ -36,7 +36,7 @@ class SettingsValidation extends FormRequest * * @return bool */ - public function authorize() + public function authorize(): bool { return true; @@ -47,7 +47,7 @@ public function authorize() * * @return array */ - public function rules() + public function rules(): array { return [ 'slack_integration' => ['boolean'], diff --git a/src/Http/routes.php b/src/Http/routes.php index adb32d2..13287e7 100755 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -4,7 +4,7 @@ 'namespace' => 'Seat\Kassie\Calendar\Http\Controllers', 'middleware' => ['web', 'auth', 'locale'], 'prefix' => 'character', -], function() { +], function(): void { Route::get('/{character}/paps', [ 'as' => 'character.view.paps', @@ -18,7 +18,7 @@ 'namespace' => 'Seat\Kassie\Calendar\Http\Controllers', 'middleware' => ['web', 'auth', 'locale'], 'prefix' => 'corporation', -], function() { +], function(): void { Route::get('/{corporation}/paps', [ 'as' => 'corporation.view.paps', @@ -44,11 +44,11 @@ 'namespace' => 'Seat\Kassie\Calendar\Http\Controllers', 'middleware' => ['web', 'auth', 'locale', 'can:calendar.view'], 'prefix' => 'calendar' -], function () { +], function (): void { Route::group([ 'prefix' => 'ajax' - ], function(){ + ], function(): void{ Route::get('/operation/{id}', [ 'as' => 'operation.detail', @@ -73,7 +73,7 @@ Route::group([ 'prefix' => 'operation' - ], function() { + ], function(): void { Route::get('/', [ 'as' => 'operation.index', @@ -130,7 +130,7 @@ Route::group([ 'prefix' => 'setting', 'middleware' => 'can:calendar.setup' - ], function() { + ], function(): void { Route::get('/', [ 'as' => 'setting.index', @@ -140,7 +140,7 @@ Route::group([ 'prefix' => 'slack' - ], function() { + ], function(): void { Route::post('update', [ 'as' => 'setting.slack.update', @@ -151,7 +151,7 @@ Route::group([ 'prefix' => 'tag' - ], function() { + ], function(): void { Route::post('create', [ 'as' => 'setting.tag.create', @@ -180,7 +180,7 @@ Route::group([ 'prefix' => 'lookup' - ], function() { + ], function(): void { Route::get('characters', 'LookupController@lookupCharacters')->name('calendar.lookups.characters'); Route::get('systems', 'LookupController@lookupSystems')->name('calendar.lookups.systems'); diff --git a/src/Models/Attendee.php b/src/Models/Attendee.php index 656c3f8..7f720a0 100755 --- a/src/Models/Attendee.php +++ b/src/Models/Attendee.php @@ -29,10 +29,7 @@ class Attendee extends Model 'comment' ]; - /** - * @var array - */ - protected $dates = ['created_at', 'updated_at']; + protected $casts = ['created_at' => 'datetime', 'updated_at' => 'datetime']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/src/Models/Operation.php b/src/Models/Operation.php index 9b01ee5..5e45eec 100755 --- a/src/Models/Operation.php +++ b/src/Models/Operation.php @@ -46,10 +46,7 @@ class Operation extends Model 'role_name', ]; - /** - * @var array - */ - protected $dates = ['start_at', 'end_at', 'created_at', 'updated_at']; + protected $casts = ['start_at' => 'datetime', 'end_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo @@ -100,7 +97,7 @@ public function staging() ->withDefault(); } - public function getIsFleetCommanderAttribute() + public function getIsFleetCommanderAttribute(): bool { if ($this->fc_character_id == null) return false; @@ -119,7 +116,7 @@ public function getDescriptionAttribute($value) { /** * @param $value */ - public function setDescriptionAttribute($value) { + public function setDescriptionAttribute($value): void { $this->attributes['description_new'] = $value; } @@ -153,7 +150,7 @@ public function getDurationAttribute() { /** * @return string */ - public function getStatusAttribute() { + public function getStatusAttribute(): string { if ($this->is_cancelled) return "cancelled"; @@ -230,7 +227,6 @@ public function routeNotificationForSlack() /** * Return true if the user can see the operation * - * @param User $user * @return bool */ public function isUserGranted(User $user) : bool diff --git a/src/Notifications/OperationActivated.php b/src/Notifications/OperationActivated.php index 4451c9c..fba7009 100755 --- a/src/Notifications/OperationActivated.php +++ b/src/Notifications/OperationActivated.php @@ -20,7 +20,7 @@ class OperationActivated extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Notifications/OperationCancelled.php b/src/Notifications/OperationCancelled.php index b527722..0e41634 100755 --- a/src/Notifications/OperationCancelled.php +++ b/src/Notifications/OperationCancelled.php @@ -20,7 +20,7 @@ class OperationCancelled extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Notifications/OperationEnded.php b/src/Notifications/OperationEnded.php index 859feee..521b3f9 100644 --- a/src/Notifications/OperationEnded.php +++ b/src/Notifications/OperationEnded.php @@ -20,7 +20,7 @@ class OperationEnded extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Notifications/OperationPinged.php b/src/Notifications/OperationPinged.php index 6e00f2b..3dc3f51 100755 --- a/src/Notifications/OperationPinged.php +++ b/src/Notifications/OperationPinged.php @@ -20,7 +20,7 @@ class OperationPinged extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Notifications/OperationPosted.php b/src/Notifications/OperationPosted.php index 27a815a..14ae451 100755 --- a/src/Notifications/OperationPosted.php +++ b/src/Notifications/OperationPosted.php @@ -20,7 +20,7 @@ class OperationPosted extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Notifications/OperationUpdated.php b/src/Notifications/OperationUpdated.php index 41ade43..2216dd6 100755 --- a/src/Notifications/OperationUpdated.php +++ b/src/Notifications/OperationUpdated.php @@ -20,7 +20,7 @@ class OperationUpdated extends Notification * @param $notifiable * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['slack']; } diff --git a/src/Observers/OperationObserver.php b/src/Observers/OperationObserver.php index 765c62e..4480138 100755 --- a/src/Observers/OperationObserver.php +++ b/src/Observers/OperationObserver.php @@ -18,10 +18,7 @@ */ class OperationObserver { - /** - * @param \Seat\Kassie\Calendar\Models\Operation $operation - */ - public function created(Operation $operation) + public function created(Operation $operation): void { if (setting('kassie.calendar.slack_integration', true) && !is_null($operation->integration) && @@ -29,10 +26,7 @@ public function created(Operation $operation) Notification::send($operation, new OperationPosted()); } - /** - * @param \Seat\Kassie\Calendar\Models\Operation $new_operation - */ - public function updating(Operation $new_operation) + public function updating(Operation $new_operation): void { if (setting('kassie.calendar.slack_integration', true) && !is_null($new_operation->integration)) { $old_operation = Operation::find($new_operation->id); diff --git a/src/database/migrations/2017_02_01_093144_create_calendar_tables.php b/src/database/migrations/2017_02_01_093144_create_calendar_tables.php index a5511e2..e57c549 100755 --- a/src/database/migrations/2017_02_01_093144_create_calendar_tables.php +++ b/src/database/migrations/2017_02_01_093144_create_calendar_tables.php @@ -11,16 +11,12 @@ class CreateCalendarTables extends Migration * * @return void */ - public function up() + public function up(): void { - Schema::create('calendar_operations', function (Blueprint $table) { + Schema::create('calendar_operations', function (Blueprint $table): void { $table->increments('id'); - if (Schema::hasTable('groups')) { - $table->bigInteger('user_id'); - } else { - $table->unsignedInteger('user_id'); - } + $table->unsignedInteger('user_id'); $table->string('title'); $table->timestamp('start_at')->nullable(); @@ -44,16 +40,12 @@ public function up() ->onDelete('cascade'); }); - Schema::create('calendar_attendees', function (Blueprint $table) { + Schema::create('calendar_attendees', function (Blueprint $table): void { $table->increments('id'); $table->integer('operation_id')->unsigned(); - if (Schema::hasTable('groups')) { - $table->bigInteger('user_id'); - } else { - $table->unsignedInteger('user_id'); - } + $table->unsignedInteger('user_id'); $table->bigInteger('character_id'); $table->enum('status', ['yes', 'no', 'maybe']); @@ -74,7 +66,7 @@ public function up() ->onDelete('cascade'); }); - Schema::create('calendar_settings', function (Blueprint $table) { + Schema::create('calendar_settings', function (Blueprint $table): void { $table->increments('id'); $table->boolean('slack_integration'); @@ -90,7 +82,7 @@ public function up() * * @return void */ - public function down() + public function down(): void { Schema::drop('calendar_attendees'); Schema::drop('calendar_operations'); diff --git a/src/database/migrations/2017_02_04_133800_alter_calendar_operations.php b/src/database/migrations/2017_02_04_133800_alter_calendar_operations.php index 0831e93..a7ae044 100755 --- a/src/database/migrations/2017_02_04_133800_alter_calendar_operations.php +++ b/src/database/migrations/2017_02_04_133800_alter_calendar_operations.php @@ -11,9 +11,9 @@ class AlterCalendarOperations extends Migration * * @return void */ - public function up() + public function up(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->dropColumn('staging'); $table->string('staging_sys')->nullable(); @@ -29,9 +29,9 @@ public function up() * * @return void */ - public function down() + public function down(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->dropForeign(['staging_sys_id']); $table->dropColumn('staging_sys'); diff --git a/src/database/migrations/2017_11_04_190700_alter_calendar_operations_description_field.php b/src/database/migrations/2017_11_04_190700_alter_calendar_operations_description_field.php index 0fe3feb..8b1ebc1 100755 --- a/src/database/migrations/2017_11_04_190700_alter_calendar_operations_description_field.php +++ b/src/database/migrations/2017_11_04_190700_alter_calendar_operations_description_field.php @@ -11,9 +11,9 @@ class AlterCalendarOperationsDescriptionField extends Migration * * @return void */ - public function up() + public function up(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->text('description_new')->nullable(); }); @@ -24,9 +24,9 @@ public function up() * * @return void */ - public function down() + public function down(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->dropColumn('description_new'); }); } diff --git a/src/database/migrations/2017_11_26_110800_update_settings_table.php b/src/database/migrations/2017_11_26_110800_update_settings_table.php index 5f12f7e..82285a9 100644 --- a/src/database/migrations/2017_11_26_110800_update_settings_table.php +++ b/src/database/migrations/2017_11_26_110800_update_settings_table.php @@ -12,7 +12,7 @@ class UpdateSettingsTable extends Migration * * @return void */ - public function up() + public function up(): void { if (Schema::hasTable('calendar_settings')) { @@ -67,11 +67,11 @@ public function up() * * @return void */ - public function down() + public function down(): void { if (!Schema::hasTable('calendar_settings')) { - Schema::create('calendar_settings', function (Blueprint $table) { + Schema::create('calendar_settings', function (Blueprint $table): void { $table->increments('id'); $table->boolean('slack_integration'); $table->string('slack_webhook'); @@ -83,31 +83,31 @@ public function down() } if (!Schema::hasColumn('calendar_settings', 'slack_integration')) { - Schema::table('calendar_settings', function(Blueprint $table) { + Schema::table('calendar_settings', function(Blueprint $table): void { $table->boolean('slack_integration')->first(); }); } if (!Schema::hasColumn('calendar_settings', 'slack_webhook')) { - Schema::table('calendar_settings', function(Blueprint $table) { + Schema::table('calendar_settings', function(Blueprint $table): void { $table->string('slack_webhook')->after('slack_integration'); }); } if (!Schema::hasColumn('calendar_settings', 'slack_emoji_importance_full')) { - Schema::table('calendar_settings', function(Blueprint $table) { + Schema::table('calendar_settings', function(Blueprint $table): void { $table->string('slack_emoji_importance_full')->after('slack_webhook'); }); } if (!Schema::hasColumn('calendar_settings', 'slack_emoji_importance_half')) { - Schema::table('calendar_settings', function(Blueprint $table) { + Schema::table('calendar_settings', function(Blueprint $table): void { $table->string('slack_emoji_importance_half')->after('slack_emoji_importance_full'); }); } if (!Schema::hasColumn('calendar_settings', 'slack_emoji_importance_empty')) { - Schema::table('calendar_settings', function(Blueprint $table) { + Schema::table('calendar_settings', function(Blueprint $table): void { $table->string('slack_emoji_importance_empty')->after('slack_emoji_importance_half'); }); } diff --git a/src/database/migrations/2017_12_21_111200_create_paps_tables.php b/src/database/migrations/2017_12_21_111200_create_paps_tables.php index dec2e43..72fe1db 100644 --- a/src/database/migrations/2017_12_21_111200_create_paps_tables.php +++ b/src/database/migrations/2017_12_21_111200_create_paps_tables.php @@ -12,9 +12,9 @@ class CreatePapsTables extends Migration { - public function up() + public function up(): void { - Schema::create('kassie_calendar_esi_tokens', function(Blueprint $table){ + Schema::create('kassie_calendar_esi_tokens', function(Blueprint $table): void{ $table->bigInteger('character_id'); $table->string('scopes'); @@ -27,7 +27,7 @@ public function up() }); - Schema::create('kassie_calendar_paps', function(Blueprint $table){ + Schema::create('kassie_calendar_paps', function(Blueprint $table): void{ $table->integer('operation_id'); $table->bigInteger('character_id'); @@ -46,7 +46,7 @@ public function up() }); } - public function down() + public function down(): void { Schema::dropIfExists('kassie_calendar_paps'); Schema::dropIfExists('kassie_calendar_esi_tokens'); diff --git a/src/database/migrations/2017_14_04_144800_alter_calendar_operations_for_tags.php b/src/database/migrations/2017_14_04_144800_alter_calendar_operations_for_tags.php index d00c226..0d4537c 100755 --- a/src/database/migrations/2017_14_04_144800_alter_calendar_operations_for_tags.php +++ b/src/database/migrations/2017_14_04_144800_alter_calendar_operations_for_tags.php @@ -11,13 +11,13 @@ class AlterCalendarOperationsForTags extends Migration * * @return void */ - public function up() + public function up(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->dropColumn('type'); }); - Schema::create('calendar_tags', function (Blueprint $table) { + Schema::create('calendar_tags', function (Blueprint $table): void { $table->increments('id'); $table->string('name'); @@ -25,7 +25,7 @@ public function up() $table->string('text_color'); }); - Schema::create('calendar_tag_operation', function (Blueprint $table) { + Schema::create('calendar_tag_operation', function (Blueprint $table): void { $table->integer('tag_id')->unsigned()->nullable(); $table->integer('operation_id')->unsigned()->nullable(); @@ -46,13 +46,13 @@ public function up() * * @return void */ - public function down() + public function down(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->enum('type', ['PvP', 'PvE', 'PvR', 'Other'])->nullable(); }); - Schema::table('calendar_tag_operation', function (Blueprint $table) { + Schema::table('calendar_tag_operation', function (Blueprint $table): void { $table->dropForeign('calendar_tag_operation_operation_id_foreign'); $table->dropForeign('calendar_tag_operation_tag_id_foreign'); }); diff --git a/src/database/migrations/2017_15_04_182100_alter_calendar_tags_for_order.php b/src/database/migrations/2017_15_04_182100_alter_calendar_tags_for_order.php index 651d2a3..5a3fd5d 100755 --- a/src/database/migrations/2017_15_04_182100_alter_calendar_tags_for_order.php +++ b/src/database/migrations/2017_15_04_182100_alter_calendar_tags_for_order.php @@ -11,9 +11,9 @@ class AlterCalendarTagsForOrder extends Migration * * @return void */ - public function up() + public function up(): void { - Schema::table('calendar_tags', function (Blueprint $table) { + Schema::table('calendar_tags', function (Blueprint $table): void { $table->string('order')->nullable()->default('0'); }); } @@ -23,9 +23,9 @@ public function up() * * @return void */ - public function down() + public function down(): void { - Schema::table('calendar_tags', function (Blueprint $table) { + Schema::table('calendar_tags', function (Blueprint $table): void { $table->dropColumn('order'); }); } diff --git a/src/database/migrations/2017_28_04_182100_alter_calendar_operations_SDE.php b/src/database/migrations/2017_28_04_182100_alter_calendar_operations_SDE.php index 279ef57..12a456c 100755 --- a/src/database/migrations/2017_28_04_182100_alter_calendar_operations_SDE.php +++ b/src/database/migrations/2017_28_04_182100_alter_calendar_operations_SDE.php @@ -12,17 +12,14 @@ class AlterCalendarOperationsSDE extends Migration * * @return void */ - public function up() + public function up(): void { try { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->dropForeign('calendar_operations_staging_sys_id_foreign'); }); } - catch (QueryException $e) { - - } - catch (PDOException $e) { + catch (QueryException|PDOException) { } } @@ -32,9 +29,9 @@ public function up() * * @return void */ - public function down() + public function down(): void { - Schema::table('calendar_operations', function (Blueprint $table) { + Schema::table('calendar_operations', function (Blueprint $table): void { $table->foreign('staging_sys_id') ->references('itemID') ->on('invUniqueNames') diff --git a/src/database/migrations/2018_01_03_172600_add_analytics.php b/src/database/migrations/2018_01_03_172600_add_analytics.php index ecf079e..9e2929d 100644 --- a/src/database/migrations/2018_01_03_172600_add_analytics.php +++ b/src/database/migrations/2018_01_03_172600_add_analytics.php @@ -7,16 +7,16 @@ class AddAnalytics extends Migration { - public function up() + public function up(): void { - Schema::table('calendar_tags', function(Blueprint $table){ + Schema::table('calendar_tags', function(Blueprint $table): void{ $table->decimal('quantifier', 5, 2)->default(1.0); $table->enum('analytics', ['strategic', 'pvp', 'mining', 'other', 'untracked'])->default('untracked'); }); - Schema::table('kassie_calendar_paps', function(Blueprint $table){ + Schema::table('kassie_calendar_paps', function(Blueprint $table): void{ $table->decimal('value', 5, 2) ->after('ship_type_id') @@ -25,15 +25,15 @@ public function up() }); } - public function down() + public function down(): void { - Schema::table('calendar_tags', function(Blueprint $table){ + Schema::table('calendar_tags', function(Blueprint $table): void{ $table->dropColumn(['quantifier', 'analytics']); }); - Schema::table('kassie_calendar_paps', function(Blueprint $table){ + Schema::table('kassie_calendar_paps', function(Blueprint $table): void{ $table->dropColumn('value'); diff --git a/src/database/migrations/2018_02_18_111413_add_role_to_operations.php b/src/database/migrations/2018_02_18_111413_add_role_to_operations.php index 8996c3d..ff6ed3c 100644 --- a/src/database/migrations/2018_02_18_111413_add_role_to_operations.php +++ b/src/database/migrations/2018_02_18_111413_add_role_to_operations.php @@ -7,18 +7,18 @@ class AddRoleToOperations extends Migration { - public function up() + public function up(): void { - Schema::table('calendar_operations', function(Blueprint $table){ + Schema::table('calendar_operations', function(Blueprint $table): void{ $table->string('role_name')->nullable(); }); } - public function down() + public function down(): void { - Schema::table('calendar_operations', function(Blueprint $table){ + Schema::table('calendar_operations', function(Blueprint $table): void{ $table->dropColumn(['role_name']); diff --git a/src/database/migrations/2018_02_23_233539_use_core_integrations.php b/src/database/migrations/2018_02_23_233539_use_core_integrations.php index 68dd9be..679959d 100644 --- a/src/database/migrations/2018_02_23_233539_use_core_integrations.php +++ b/src/database/migrations/2018_02_23_233539_use_core_integrations.php @@ -8,7 +8,7 @@ class UseCoreIntegrations extends Migration { - public function up() + public function up(): void { $integration = setting('kassie.calendar.slack_webhook', true); @@ -17,28 +17,28 @@ public function up() DB::table('integrations')->insert([ 'name' => 'SeAT Calendar', 'type' => 'slack', - 'settings' => json_encode((object) ['url' => $integration]), + 'settings' => json_encode((object) ['url' => $integration], JSON_THROW_ON_ERROR), ]); DB::table('global_settings')->where('name', 'kassie.calendar.slack_webhook')->delete(); } - Schema::table('calendar_operations', function(Blueprint $table){ + Schema::table('calendar_operations', function(Blueprint $table): void{ $table->unsignedInteger('integration_id')->nullable(); }); } - public function down() + public function down(): void { $integration = DB::table('integrations')->where('name', 'SeAT Calendar')->where('type', 'slack')->first(); if (! is_null($integration)) { - setting(['kassie.calendar.slack_webhook' => json_decode($integration->settings)->url], true); + setting(['kassie.calendar.slack_webhook' => json_decode((string) $integration->settings, null, 512, JSON_THROW_ON_ERROR)->url], true); } - Schema::table('calendar_operations', function(Blueprint $table){ + Schema::table('calendar_operations', function(Blueprint $table): void{ $table->dropColumn('integration_id'); diff --git a/src/database/migrations/2020_04_05_002056_upgrade_calendar_operations_to_v4.php b/src/database/migrations/2020_04_05_002056_upgrade_calendar_operations_to_v4.php index 3105f45..b9cb5f7 100644 --- a/src/database/migrations/2020_04_05_002056_upgrade_calendar_operations_to_v4.php +++ b/src/database/migrations/2020_04_05_002056_upgrade_calendar_operations_to_v4.php @@ -8,12 +8,12 @@ */ class UpgradeCalendarOperationsToV4 extends Migration { - public function up() + public function up(): void { DB::table('calendar_operations') ->join('mig_groups', 'user_id', '=', 'old_user_id') ->orderBy('user_id') - ->each(function ($row) { + ->each(function ($row): void { DB::table('calendar_operations') ->where('user_id', $row->old_user_id) ->update([ @@ -23,12 +23,12 @@ public function up() } - public function down() + public function down(): void { DB::table('calendar_operations') ->join('mig_groups', 'user_id', '=', 'new_user_id') ->orderBy('user_id') - ->each(function ($row) { + ->each(function ($row): void { DB::table('calendar_operations') ->where('user_id', $row->new_user_id) ->update([ diff --git a/src/database/migrations/2021_12_31_213410_default_notification_settings.php b/src/database/migrations/2021_12_31_213410_default_notification_settings.php index 5e15369..3c09fc0 100644 --- a/src/database/migrations/2021_12_31_213410_default_notification_settings.php +++ b/src/database/migrations/2021_12_31_213410_default_notification_settings.php @@ -7,7 +7,7 @@ class DefaultNotificationSettings extends Migration { - const DEFAULT_SETTINGS = [ + final public const DEFAULT_SETTINGS = [ 'kassie.calendar.notify_create_operation' => true, 'kassie.calendar.notify_update_operation' => true, 'kassie.calendar.notify_cancel_operation' => true, @@ -21,7 +21,7 @@ class DefaultNotificationSettings extends Migration * * @return void */ - public function up() + public function up(): void { foreach (self::DEFAULT_SETTINGS as $name => $value) { setting([$name, $value], true); @@ -33,7 +33,7 @@ public function up() * * @return void */ - public function down() + public function down(): void { GlobalSetting::whereIn('name', array_keys(self::DEFAULT_SETTINGS))->delete(); } diff --git a/src/database/seeds/CalendarSettingsTableSeeder.php b/src/database/seeds/CalendarSettingsTableSeeder.php index 70d142e..bba43b3 100755 --- a/src/database/seeds/CalendarSettingsTableSeeder.php +++ b/src/database/seeds/CalendarSettingsTableSeeder.php @@ -7,7 +7,7 @@ class CalendarSettingsTableSeeder extends Seeder { - public function run() + public function run(): void { setting([ 'kassie.calendar.slack_integration', diff --git a/src/database/seeds/CalendarTagsSeeder.php b/src/database/seeds/CalendarTagsSeeder.php index 65e4722..227acf8 100755 --- a/src/database/seeds/CalendarTagsSeeder.php +++ b/src/database/seeds/CalendarTagsSeeder.php @@ -8,7 +8,7 @@ class CalendarTagsSeeder extends Seeder { - public function run() + public function run(): void { DB::table('calendar_tags')->insert([ [ diff --git a/src/database/seeds/ScheduleSeeder.php b/src/database/seeds/ScheduleSeeder.php index c992923..b9c369e 100755 --- a/src/database/seeds/ScheduleSeeder.php +++ b/src/database/seeds/ScheduleSeeder.php @@ -8,7 +8,7 @@ class ScheduleSeeder extends Seeder { - public function run() + public function run(): void { $job = [ 'command' => 'calendar:remind',