diff --git a/config/playground-matrix-resource.php b/config/playground-matrix-resource.php index b591e4b..c0a3986 100644 --- a/config/playground-matrix-resource.php +++ b/config/playground-matrix-resource.php @@ -4,7 +4,6 @@ return [ 'about' => (bool) env('PLAYGROUND_MATRIX_RESOURCE_ABOUT', true), - 'default_key' => env('PLAYGROUND_MATRIX_RESOURCE_DEFAULT_KEY', ''), 'middleware' => [ 'default' => env('PLAYGROUND_MATRIX_RESOURCE_MIDDLEWARE_DEFAULT', ['web']), 'auth' => env('PLAYGROUND_MATRIX_RESOURCE_MIDDLEWARE_AUTH', ['web', 'auth']), diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 433de21..b249ebb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,7 +17,5 @@ parameters: treatPhpDocTypesAsCertain: false - checkGenericClassInNonGenericObjectType: false - # editorUrl: 'vscode://file/%%file%%:%%line%%' # editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' \ No newline at end of file diff --git a/src/Http/Controllers/BacklogController.php b/src/Http/Controllers/BacklogController.php index c4757c7..48a6e10 100644 --- a/src/Http/Controllers/BacklogController.php +++ b/src/Http/Controllers/BacklogController.php @@ -24,7 +24,7 @@ class BacklogController extends Controller * @var array */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Backlog', 'model_label_plural' => 'Backlogs', 'model_route' => 'playground.matrix.resource.backlogs', @@ -40,13 +40,13 @@ class BacklogController extends Controller ]; /** - * CREATE the Backlog resource in storage. + * Create the Backlog resource in storage. * * @route GET /resource/matrix/backlogs/create playground.matrix.resource.backlogs.create */ public function create( Requests\Backlog\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Backlog { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $backlog = new Backlog($validated); + if ($request->expectsJson()) { + return (new Resources\Backlog($backlog))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $backlog->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Backlog $backlog, Requests\Backlog\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Backlog { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Backlog($backlog))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $backlog->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $backlog->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $backlog->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/BoardController.php b/src/Http/Controllers/BoardController.php index 45ca42f..ccdab2d 100644 --- a/src/Http/Controllers/BoardController.php +++ b/src/Http/Controllers/BoardController.php @@ -24,7 +24,7 @@ class BoardController extends Controller * @var array */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Board', 'model_label_plural' => 'Boards', 'model_route' => 'playground.matrix.resource.boards', @@ -40,13 +40,13 @@ class BoardController extends Controller ]; /** - * CREATE the Board resource in storage. + * Create the Board resource in storage. * * @route GET /resource/matrix/boards/create playground.matrix.resource.boards.create */ public function create( Requests\Board\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Board { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $board = new Board($validated); + if ($request->expectsJson()) { + return (new Resources\Board($board))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $board->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Board $board, Requests\Board\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Board { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Board($board))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $board->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $board->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $board->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/EpicController.php b/src/Http/Controllers/EpicController.php index 2501dd6..8964a90 100644 --- a/src/Http/Controllers/EpicController.php +++ b/src/Http/Controllers/EpicController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Epic', 'model_label_plural' => 'Epics', 'model_route' => 'playground.matrix.resource.epics', @@ -50,19 +40,26 @@ class EpicController extends Controller ]; /** - * CREATE the Epic resource in storage. + * Create the Epic resource in storage. * * @route GET /resource/matrix/epics/create playground.matrix.resource.epics.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Epic\CreateRequest $request + ): JsonResponse|View|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); $epic = new Epic($validated); + if ($request->expectsJson()) { + return (new Resources\Epic($epic))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $epic->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::epic/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Epic $epic, - EditRequest $request - ): JsonResponse|View { + Requests\Epic\EditRequest $request + ): JsonResponse|View|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Epic($epic))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $epic->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $epic->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $epic->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::epic/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Epic $epic, - DestroyRequest $request + Requests\Epic\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Epic $epic, - LockRequest $request - ): JsonResponse|RedirectResponse|EpicResource { + Requests\Epic\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); - $epic->setAttribute('locked', true); + $epic->locked = true; $epic->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics.show', ['epic' => $epic->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['epic' => $epic->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.epics */ public function index( - IndexRequest $request - ): JsonResponse|View|EpicCollection { + Requests\Epic\IndexRequest $request + ): JsonResponse|View|Resources\EpicCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new EpicCollection($paginator))->response($request); + return (new Resources\EpicCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::epic/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Epic $epic, - RestoreRequest $request - ): JsonResponse|RedirectResponse|EpicResource { + Requests\Epic\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $epic->restore(); if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics.show', ['epic' => $epic->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['epic' => $epic->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Epic $epic, - ShowRequest $request - ): JsonResponse|View|EpicResource { + Requests\Epic\ShowRequest $request + ): JsonResponse|View|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::epic/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.epics.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|EpicResource { + Requests\Epic\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $epic->save(); if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics.show', ['epic' => $epic->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['epic' => $epic->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Epic $epic, - UnlockRequest $request - ): JsonResponse|RedirectResponse|EpicResource { + Requests\Epic\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); - $epic->setAttribute('locked', false); + $epic->locked = false; $epic->save(); if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics.show', ['epic' => $epic->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['epic' => $epic->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Epic $epic, - UpdateRequest $request - ): JsonResponse|RedirectResponse|EpicResource { + Requests\Epic\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Epic { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $epic->update($validated); if ($request->expectsJson()) { - return (new EpicResource($epic))->response($request); + return (new Resources\Epic($epic))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.epics.show', ['epic' => $epic->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['epic' => $epic->id])); } } diff --git a/src/Http/Controllers/FlowController.php b/src/Http/Controllers/FlowController.php index 68b26e8..c669690 100644 --- a/src/Http/Controllers/FlowController.php +++ b/src/Http/Controllers/FlowController.php @@ -24,7 +24,7 @@ class FlowController extends Controller * @var array */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Flow', 'model_label_plural' => 'Flows', 'model_route' => 'playground.matrix.resource.flows', @@ -40,13 +40,13 @@ class FlowController extends Controller ]; /** - * CREATE the Flow resource in storage. + * Create the Flow resource in storage. * * @route GET /resource/matrix/flows/create playground.matrix.resource.flows.create */ public function create( Requests\Flow\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Flow { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $flow = new Flow($validated); + if ($request->expectsJson()) { + return (new Resources\Flow($flow))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $flow->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Flow $flow, Requests\Flow\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Flow { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Flow($flow))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $flow->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $flow->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $flow->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/IndexController.php b/src/Http/Controllers/IndexController.php index 050a4ed..e893341 100644 --- a/src/Http/Controllers/IndexController.php +++ b/src/Http/Controllers/IndexController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Matrix', 'model_label_plural' => 'Matrices', 'model_route' => 'playground.matrix.resource.matrices', @@ -40,13 +40,13 @@ class MatrixController extends Controller ]; /** - * CREATE the Matrix resource in storage. + * Create the Matrix resource in storage. * * @route GET /resource/matrix/matrices/create playground.matrix.resource.matrices.create */ public function create( Requests\Matrix\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Matrix { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $matrix = new Matrix($validated); + if ($request->expectsJson()) { + return (new Resources\Matrix($matrix))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $matrix->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Matrix $matrix, Requests\Matrix\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Matrix { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Matrix($matrix))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $matrix->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $matrix->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $matrix->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/MilestoneController.php b/src/Http/Controllers/MilestoneController.php index d345542..a023b68 100644 --- a/src/Http/Controllers/MilestoneController.php +++ b/src/Http/Controllers/MilestoneController.php @@ -24,7 +24,7 @@ class MilestoneController extends Controller * @var array */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Milestone', 'model_label_plural' => 'Milestones', 'model_route' => 'playground.matrix.resource.milestones', @@ -40,13 +40,13 @@ class MilestoneController extends Controller ]; /** - * CREATE the Milestone resource in storage. + * Create the Milestone resource in storage. * * @route GET /resource/matrix/milestones/create playground.matrix.resource.milestones.create */ public function create( Requests\Milestone\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Milestone { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $milestone = new Milestone($validated); + if ($request->expectsJson()) { + return (new Resources\Milestone($milestone))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $milestone->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Milestone $milestone, Requests\Milestone\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Milestone { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Milestone($milestone))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $milestone->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $milestone->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $milestone->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/NoteController.php b/src/Http/Controllers/NoteController.php index 57ae58b..bfdb760 100644 --- a/src/Http/Controllers/NoteController.php +++ b/src/Http/Controllers/NoteController.php @@ -24,7 +24,7 @@ class NoteController extends Controller * @var array */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Note', 'model_label_plural' => 'Notes', 'model_route' => 'playground.matrix.resource.notes', @@ -40,13 +40,13 @@ class NoteController extends Controller ]; /** - * CREATE the Note resource in storage. + * Create the Note resource in storage. * * @route GET /resource/matrix/notes/create playground.matrix.resource.notes.create */ public function create( Requests\Note\CreateRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Note { $validated = $request->validated(); @@ -54,6 +54,12 @@ public function create( $note = new Note($validated); + if ($request->expectsJson()) { + return (new Resources\Note($note))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -71,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $note->toArray(); if (! empty($validated['_return_url'])) { @@ -97,12 +99,25 @@ public function create( public function edit( Note $note, Requests\Note\EditRequest $request - ): JsonResponse|View { + ): JsonResponse|View|Resources\Note { $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Note($note))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $note->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $note->id, @@ -120,17 +135,6 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $note->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); diff --git a/src/Http/Controllers/ProjectController.php b/src/Http/Controllers/ProjectController.php index c52e0a1..0bdc6b6 100644 --- a/src/Http/Controllers/ProjectController.php +++ b/src/Http/Controllers/ProjectController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Project', 'model_label_plural' => 'Projects', 'model_route' => 'playground.matrix.resource.projects', @@ -50,19 +40,26 @@ class ProjectController extends Controller ]; /** - * CREATE the Project resource in storage. + * Create the Project resource in storage. * * @route GET /resource/matrix/projects/create playground.matrix.resource.projects.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Project\CreateRequest $request + ): JsonResponse|View|Resources\Project { + $validated = $request->validated(); $user = $request->user(); $project = new Project($validated); + if ($request->expectsJson()) { + return (new Resources\Project($project))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $project->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::project/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Project $project, - EditRequest $request - ): JsonResponse|View { + Requests\Project\EditRequest $request + ): JsonResponse|View|Resources\Project { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Project($project))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $project->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $project->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $project->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::project/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Project $project, - DestroyRequest $request + Requests\Project\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Project $project, - LockRequest $request - ): JsonResponse|RedirectResponse|ProjectResource { + Requests\Project\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Project { + $validated = $request->validated(); $user = $request->user(); - $project->setAttribute('locked', true); + $project->locked = true; $project->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects.show', ['project' => $project->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['project' => $project->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.projects */ public function index( - IndexRequest $request - ): JsonResponse|View|ProjectCollection { + Requests\Project\IndexRequest $request + ): JsonResponse|View|Resources\ProjectCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new ProjectCollection($paginator))->response($request); + return (new Resources\ProjectCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::project/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Project $project, - RestoreRequest $request - ): JsonResponse|RedirectResponse|ProjectResource { + Requests\Project\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Project { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $project->restore(); if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects.show', ['project' => $project->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['project' => $project->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Project $project, - ShowRequest $request - ): JsonResponse|View|ProjectResource { + Requests\Project\ShowRequest $request + ): JsonResponse|View|Resources\Project { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::project/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.projects.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|ProjectResource { + Requests\Project\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Project { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $project->save(); if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects.show', ['project' => $project->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['project' => $project->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Project $project, - UnlockRequest $request - ): JsonResponse|RedirectResponse|ProjectResource { + Requests\Project\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Project { + $validated = $request->validated(); $user = $request->user(); - $project->setAttribute('locked', false); + $project->locked = false; $project->save(); if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects.show', ['project' => $project->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['project' => $project->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Project $project, - UpdateRequest $request - ): JsonResponse|RedirectResponse|ProjectResource { + Requests\Project\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Project { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $project->update($validated); if ($request->expectsJson()) { - return (new ProjectResource($project))->response($request); + return (new Resources\Project($project))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.projects.show', ['project' => $project->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['project' => $project->id])); } } diff --git a/src/Http/Controllers/ReleaseController.php b/src/Http/Controllers/ReleaseController.php index 6cc5fa6..5c2aaae 100644 --- a/src/Http/Controllers/ReleaseController.php +++ b/src/Http/Controllers/ReleaseController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Release', 'model_label_plural' => 'Releases', 'model_route' => 'playground.matrix.resource.releases', @@ -50,19 +40,26 @@ class ReleaseController extends Controller ]; /** - * CREATE the Release resource in storage. + * Create the Release resource in storage. * * @route GET /resource/matrix/releases/create playground.matrix.resource.releases.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Release\CreateRequest $request + ): JsonResponse|View|Resources\Release { + $validated = $request->validated(); $user = $request->user(); $release = new Release($validated); + if ($request->expectsJson()) { + return (new Resources\Release($release))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $release->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::release/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Release $release, - EditRequest $request - ): JsonResponse|View { + Requests\Release\EditRequest $request + ): JsonResponse|View|Resources\Release { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Release($release))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $release->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $release->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $release->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::release/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Release $release, - DestroyRequest $request + Requests\Release\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Release $release, - LockRequest $request - ): JsonResponse|RedirectResponse|ReleaseResource { + Requests\Release\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Release { + $validated = $request->validated(); $user = $request->user(); - $release->setAttribute('locked', true); + $release->locked = true; $release->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases.show', ['release' => $release->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['release' => $release->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.releases */ public function index( - IndexRequest $request - ): JsonResponse|View|ReleaseCollection { + Requests\Release\IndexRequest $request + ): JsonResponse|View|Resources\ReleaseCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new ReleaseCollection($paginator))->response($request); + return (new Resources\ReleaseCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::release/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Release $release, - RestoreRequest $request - ): JsonResponse|RedirectResponse|ReleaseResource { + Requests\Release\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Release { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $release->restore(); if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases.show', ['release' => $release->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['release' => $release->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Release $release, - ShowRequest $request - ): JsonResponse|View|ReleaseResource { + Requests\Release\ShowRequest $request + ): JsonResponse|View|Resources\Release { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::release/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.releases.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|ReleaseResource { + Requests\Release\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Release { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $release->save(); if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases.show', ['release' => $release->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['release' => $release->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Release $release, - UnlockRequest $request - ): JsonResponse|RedirectResponse|ReleaseResource { + Requests\Release\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Release { + $validated = $request->validated(); $user = $request->user(); - $release->setAttribute('locked', false); + $release->locked = false; $release->save(); if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases.show', ['release' => $release->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['release' => $release->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Release $release, - UpdateRequest $request - ): JsonResponse|RedirectResponse|ReleaseResource { + Requests\Release\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Release { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $release->update($validated); if ($request->expectsJson()) { - return (new ReleaseResource($release))->response($request); + return (new Resources\Release($release))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.releases.show', ['release' => $release->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['release' => $release->id])); } } diff --git a/src/Http/Controllers/RoadmapController.php b/src/Http/Controllers/RoadmapController.php index 44245ad..c39f061 100644 --- a/src/Http/Controllers/RoadmapController.php +++ b/src/Http/Controllers/RoadmapController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Roadmap', 'model_label_plural' => 'Roadmaps', 'model_route' => 'playground.matrix.resource.roadmaps', @@ -50,19 +40,26 @@ class RoadmapController extends Controller ]; /** - * CREATE the Roadmap resource in storage. + * Create the Roadmap resource in storage. * * @route GET /resource/matrix/roadmaps/create playground.matrix.resource.roadmaps.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Roadmap\CreateRequest $request + ): JsonResponse|View|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); $roadmap = new Roadmap($validated); + if ($request->expectsJson()) { + return (new Resources\Roadmap($roadmap))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $roadmap->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::roadmap/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Roadmap $roadmap, - EditRequest $request - ): JsonResponse|View { + Requests\Roadmap\EditRequest $request + ): JsonResponse|View|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Roadmap($roadmap))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $roadmap->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $roadmap->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $roadmap->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::roadmap/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Roadmap $roadmap, - DestroyRequest $request + Requests\Roadmap\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Roadmap $roadmap, - LockRequest $request - ): JsonResponse|RedirectResponse|RoadmapResource { + Requests\Roadmap\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); - $roadmap->setAttribute('locked', true); + $roadmap->locked = true; $roadmap->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps.show', ['roadmap' => $roadmap->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['roadmap' => $roadmap->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.roadmaps */ public function index( - IndexRequest $request - ): JsonResponse|View|RoadmapCollection { + Requests\Roadmap\IndexRequest $request + ): JsonResponse|View|Resources\RoadmapCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new RoadmapCollection($paginator))->response($request); + return (new Resources\RoadmapCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::roadmap/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Roadmap $roadmap, - RestoreRequest $request - ): JsonResponse|RedirectResponse|RoadmapResource { + Requests\Roadmap\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $roadmap->restore(); if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps.show', ['roadmap' => $roadmap->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['roadmap' => $roadmap->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Roadmap $roadmap, - ShowRequest $request - ): JsonResponse|View|RoadmapResource { + Requests\Roadmap\ShowRequest $request + ): JsonResponse|View|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::roadmap/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.roadmaps.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|RoadmapResource { + Requests\Roadmap\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $roadmap->save(); if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps.show', ['roadmap' => $roadmap->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['roadmap' => $roadmap->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Roadmap $roadmap, - UnlockRequest $request - ): JsonResponse|RedirectResponse|RoadmapResource { + Requests\Roadmap\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); - $roadmap->setAttribute('locked', false); + $roadmap->locked = false; $roadmap->save(); if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps.show', ['roadmap' => $roadmap->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['roadmap' => $roadmap->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Roadmap $roadmap, - UpdateRequest $request - ): JsonResponse|RedirectResponse|RoadmapResource { + Requests\Roadmap\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Roadmap { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $roadmap->update($validated); if ($request->expectsJson()) { - return (new RoadmapResource($roadmap))->response($request); + return (new Resources\Roadmap($roadmap))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.roadmaps.show', ['roadmap' => $roadmap->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['roadmap' => $roadmap->id])); } } diff --git a/src/Http/Controllers/SourceController.php b/src/Http/Controllers/SourceController.php index d100d89..73fdbad 100644 --- a/src/Http/Controllers/SourceController.php +++ b/src/Http/Controllers/SourceController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Source', 'model_label_plural' => 'Sources', 'model_route' => 'playground.matrix.resource.sources', @@ -50,19 +40,26 @@ class SourceController extends Controller ]; /** - * CREATE the Source resource in storage. + * Create the Source resource in storage. * * @route GET /resource/matrix/sources/create playground.matrix.resource.sources.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Source\CreateRequest $request + ): JsonResponse|View|Resources\Source { + $validated = $request->validated(); $user = $request->user(); $source = new Source($validated); + if ($request->expectsJson()) { + return (new Resources\Source($source))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $source->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::source/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Source $source, - EditRequest $request - ): JsonResponse|View { + Requests\Source\EditRequest $request + ): JsonResponse|View|Resources\Source { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Source($source))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $source->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $source->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $source->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::source/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Source $source, - DestroyRequest $request + Requests\Source\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Source $source, - LockRequest $request - ): JsonResponse|RedirectResponse|SourceResource { + Requests\Source\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Source { + $validated = $request->validated(); $user = $request->user(); - $source->setAttribute('locked', true); + $source->locked = true; $source->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources.show', ['source' => $source->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['source' => $source->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.sources */ public function index( - IndexRequest $request - ): JsonResponse|View|SourceCollection { + Requests\Source\IndexRequest $request + ): JsonResponse|View|Resources\SourceCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new SourceCollection($paginator))->response($request); + return (new Resources\SourceCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::source/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Source $source, - RestoreRequest $request - ): JsonResponse|RedirectResponse|SourceResource { + Requests\Source\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Source { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $source->restore(); if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources.show', ['source' => $source->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['source' => $source->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Source $source, - ShowRequest $request - ): JsonResponse|View|SourceResource { + Requests\Source\ShowRequest $request + ): JsonResponse|View|Resources\Source { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::source/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.sources.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|SourceResource { + Requests\Source\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Source { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $source->save(); if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources.show', ['source' => $source->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['source' => $source->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Source $source, - UnlockRequest $request - ): JsonResponse|RedirectResponse|SourceResource { + Requests\Source\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Source { + $validated = $request->validated(); $user = $request->user(); - $source->setAttribute('locked', false); + $source->locked = false; $source->save(); if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources.show', ['source' => $source->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['source' => $source->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Source $source, - UpdateRequest $request - ): JsonResponse|RedirectResponse|SourceResource { + Requests\Source\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Source { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $source->update($validated); if ($request->expectsJson()) { - return (new SourceResource($source))->response($request); + return (new Resources\Source($source))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sources.show', ['source' => $source->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['source' => $source->id])); } } diff --git a/src/Http/Controllers/SprintController.php b/src/Http/Controllers/SprintController.php index 0841816..6f8f7ac 100644 --- a/src/Http/Controllers/SprintController.php +++ b/src/Http/Controllers/SprintController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Sprint', 'model_label_plural' => 'Sprints', 'model_route' => 'playground.matrix.resource.sprints', @@ -50,19 +40,26 @@ class SprintController extends Controller ]; /** - * CREATE the Sprint resource in storage. + * Create the Sprint resource in storage. * * @route GET /resource/matrix/sprints/create playground.matrix.resource.sprints.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Sprint\CreateRequest $request + ): JsonResponse|View|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); $sprint = new Sprint($validated); + if ($request->expectsJson()) { + return (new Resources\Sprint($sprint))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $sprint->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::sprint/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Sprint $sprint, - EditRequest $request - ): JsonResponse|View { + Requests\Sprint\EditRequest $request + ): JsonResponse|View|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Sprint($sprint))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $sprint->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $sprint->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $sprint->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::sprint/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Sprint $sprint, - DestroyRequest $request + Requests\Sprint\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Sprint $sprint, - LockRequest $request - ): JsonResponse|RedirectResponse|SprintResource { + Requests\Sprint\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); - $sprint->setAttribute('locked', true); + $sprint->locked = true; $sprint->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints.show', ['sprint' => $sprint->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['sprint' => $sprint->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.sprints */ public function index( - IndexRequest $request - ): JsonResponse|View|SprintCollection { + Requests\Sprint\IndexRequest $request + ): JsonResponse|View|Resources\SprintCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new SprintCollection($paginator))->response($request); + return (new Resources\SprintCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::sprint/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Sprint $sprint, - RestoreRequest $request - ): JsonResponse|RedirectResponse|SprintResource { + Requests\Sprint\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $sprint->restore(); if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints.show', ['sprint' => $sprint->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['sprint' => $sprint->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Sprint $sprint, - ShowRequest $request - ): JsonResponse|View|SprintResource { + Requests\Sprint\ShowRequest $request + ): JsonResponse|View|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::sprint/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.sprints.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|SprintResource { + Requests\Sprint\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $sprint->save(); if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints.show', ['sprint' => $sprint->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['sprint' => $sprint->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Sprint $sprint, - UnlockRequest $request - ): JsonResponse|RedirectResponse|SprintResource { + Requests\Sprint\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); - $sprint->setAttribute('locked', false); + $sprint->locked = false; $sprint->save(); if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints.show', ['sprint' => $sprint->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['sprint' => $sprint->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Sprint $sprint, - UpdateRequest $request - ): JsonResponse|RedirectResponse|SprintResource { + Requests\Sprint\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Sprint { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $sprint->update($validated); if ($request->expectsJson()) { - return (new SprintResource($sprint))->response($request); + return (new Resources\Sprint($sprint))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.sprints.show', ['sprint' => $sprint->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['sprint' => $sprint->id])); } } diff --git a/src/Http/Controllers/TagController.php b/src/Http/Controllers/TagController.php index b8912d9..00edde3 100644 --- a/src/Http/Controllers/TagController.php +++ b/src/Http/Controllers/TagController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Tag', 'model_label_plural' => 'Tags', 'model_route' => 'playground.matrix.resource.tags', @@ -50,19 +40,26 @@ class TagController extends Controller ]; /** - * CREATE the Tag resource in storage. + * Create the Tag resource in storage. * * @route GET /resource/matrix/tags/create playground.matrix.resource.tags.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Tag\CreateRequest $request + ): JsonResponse|View|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); $tag = new Tag($validated); + if ($request->expectsJson()) { + return (new Resources\Tag($tag))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $tag->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::tag/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Tag $tag, - EditRequest $request - ): JsonResponse|View { + Requests\Tag\EditRequest $request + ): JsonResponse|View|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Tag($tag))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $tag->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $tag->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $tag->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::tag/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Tag $tag, - DestroyRequest $request + Requests\Tag\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Tag $tag, - LockRequest $request - ): JsonResponse|RedirectResponse|TagResource { + Requests\Tag\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); - $tag->setAttribute('locked', true); + $tag->locked = true; $tag->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags.show', ['tag' => $tag->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['tag' => $tag->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.tags */ public function index( - IndexRequest $request - ): JsonResponse|View|TagCollection { + Requests\Tag\IndexRequest $request + ): JsonResponse|View|Resources\TagCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new TagCollection($paginator))->response($request); + return (new Resources\TagCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::tag/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Tag $tag, - RestoreRequest $request - ): JsonResponse|RedirectResponse|TagResource { + Requests\Tag\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $tag->restore(); if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags.show', ['tag' => $tag->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['tag' => $tag->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Tag $tag, - ShowRequest $request - ): JsonResponse|View|TagResource { + Requests\Tag\ShowRequest $request + ): JsonResponse|View|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::tag/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.tags.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|TagResource { + Requests\Tag\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $tag->save(); if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags.show', ['tag' => $tag->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['tag' => $tag->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Tag $tag, - UnlockRequest $request - ): JsonResponse|RedirectResponse|TagResource { + Requests\Tag\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); - $tag->setAttribute('locked', false); + $tag->locked = false; $tag->save(); if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags.show', ['tag' => $tag->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['tag' => $tag->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Tag $tag, - UpdateRequest $request - ): JsonResponse|RedirectResponse|TagResource { + Requests\Tag\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Tag { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $tag->update($validated); if ($request->expectsJson()) { - return (new TagResource($tag))->response($request); + return (new Resources\Tag($tag))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tags.show', ['tag' => $tag->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['tag' => $tag->id])); } } diff --git a/src/Http/Controllers/TeamController.php b/src/Http/Controllers/TeamController.php index db0a079..dc701fe 100644 --- a/src/Http/Controllers/TeamController.php +++ b/src/Http/Controllers/TeamController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Team', 'model_label_plural' => 'Teams', 'model_route' => 'playground.matrix.resource.teams', @@ -50,19 +40,26 @@ class TeamController extends Controller ]; /** - * CREATE the Team resource in storage. + * Create the Team resource in storage. * * @route GET /resource/matrix/teams/create playground.matrix.resource.teams.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Team\CreateRequest $request + ): JsonResponse|View|Resources\Team { + $validated = $request->validated(); $user = $request->user(); $team = new Team($validated); + if ($request->expectsJson()) { + return (new Resources\Team($team))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $team->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::team/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Team $team, - EditRequest $request - ): JsonResponse|View { + Requests\Team\EditRequest $request + ): JsonResponse|View|Resources\Team { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Team($team))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $team->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $team->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $team->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::team/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Team $team, - DestroyRequest $request + Requests\Team\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Team $team, - LockRequest $request - ): JsonResponse|RedirectResponse|TeamResource { + Requests\Team\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Team { + $validated = $request->validated(); $user = $request->user(); - $team->setAttribute('locked', true); + $team->locked = true; $team->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams.show', ['team' => $team->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['team' => $team->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.teams */ public function index( - IndexRequest $request - ): JsonResponse|View|TeamCollection { + Requests\Team\IndexRequest $request + ): JsonResponse|View|Resources\TeamCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new TeamCollection($paginator))->response($request); + return (new Resources\TeamCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::team/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Team $team, - RestoreRequest $request - ): JsonResponse|RedirectResponse|TeamResource { + Requests\Team\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Team { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $team->restore(); if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams.show', ['team' => $team->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['team' => $team->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Team $team, - ShowRequest $request - ): JsonResponse|View|TeamResource { + Requests\Team\ShowRequest $request + ): JsonResponse|View|Resources\Team { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::team/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.teams.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|TeamResource { + Requests\Team\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Team { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $team->save(); if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams.show', ['team' => $team->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['team' => $team->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Team $team, - UnlockRequest $request - ): JsonResponse|RedirectResponse|TeamResource { + Requests\Team\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Team { + $validated = $request->validated(); $user = $request->user(); - $team->setAttribute('locked', false); + $team->locked = false; $team->save(); if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams.show', ['team' => $team->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['team' => $team->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Team $team, - UpdateRequest $request - ): JsonResponse|RedirectResponse|TeamResource { + Requests\Team\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Team { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $team->update($validated); if ($request->expectsJson()) { - return (new TeamResource($team))->response($request); + return (new Resources\Team($team))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.teams.show', ['team' => $team->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['team' => $team->id])); } } diff --git a/src/Http/Controllers/TicketController.php b/src/Http/Controllers/TicketController.php index 2d1b11f..3ec50ec 100644 --- a/src/Http/Controllers/TicketController.php +++ b/src/Http/Controllers/TicketController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Ticket', 'model_label_plural' => 'Tickets', 'model_route' => 'playground.matrix.resource.tickets', @@ -50,19 +43,26 @@ class TicketController extends Controller ]; /** - * CREATE the Ticket resource in storage. + * Create the Ticket resource in storage. * * @route GET /resource/matrix/tickets/create playground.matrix.resource.tickets.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Ticket\CreateRequest $request + ): JsonResponse|View|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); $ticket = new Ticket($validated); + if ($request->expectsJson()) { + return (new Resources\Ticket($ticket))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +80,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $ticket->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +91,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::ticket/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +101,26 @@ public function create( */ public function edit( Ticket $ticket, - EditRequest $request - ): JsonResponse|View { + Requests\Ticket\EditRequest $request + ): JsonResponse|View|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Ticket($ticket))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $ticket->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $ticket->id, @@ -131,23 +138,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $ticket->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::ticket/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +150,9 @@ public function edit( */ public function destroy( Ticket $ticket, - DestroyRequest $request + Requests\Ticket\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +171,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tickets')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +181,14 @@ public function destroy( */ public function lock( Ticket $ticket, - LockRequest $request - ): JsonResponse|RedirectResponse|TicketResource { + Requests\Ticket\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); - $ticket->setAttribute('locked', true); + $ticket->locked = true; $ticket->save(); @@ -205,7 +200,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +209,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tickets.show', ['ticket' => $ticket->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['ticket' => $ticket->id])); } /** @@ -223,8 +221,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.tickets */ public function index( - IndexRequest $request - ): JsonResponse|View|TicketCollection { + Requests\Ticket\IndexRequest $request + ): JsonResponse|View|Resources\TicketCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +233,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +258,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new TicketCollection($paginator))->response($request); + return (new Resources\TicketCollection($paginator))->response($request); } $meta = [ @@ -284,10 +284,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::ticket/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +294,9 @@ public function index( */ public function restore( Ticket $ticket, - RestoreRequest $request - ): JsonResponse|RedirectResponse|TicketResource { + Requests\Ticket\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +304,7 @@ public function restore( $ticket->restore(); if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +313,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tickets.show', ['ticket' => $ticket->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['ticket' => $ticket->id])); } /** @@ -325,8 +326,9 @@ public function restore( */ public function show( Ticket $ticket, - ShowRequest $request - ): JsonResponse|View|TicketResource { + Requests\Ticket\ShowRequest $request + ): JsonResponse|View|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +342,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +353,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::ticket/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +362,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.tickets.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|TicketResource { + Requests\Ticket\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); @@ -378,7 +378,7 @@ public function store( $ticket->save(); if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -387,7 +387,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tickets.show', ['ticket' => $ticket->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['ticket' => $ticket->id])); } /** @@ -397,18 +400,19 @@ public function store( */ public function unlock( Ticket $ticket, - UnlockRequest $request - ): JsonResponse|RedirectResponse|TicketResource { + Requests\Ticket\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); - $ticket->setAttribute('locked', false); + $ticket->locked = false; $ticket->save(); if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -417,7 +421,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.tickets.show', ['ticket' => $ticket->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['ticket' => $ticket->id])); } /** @@ -427,16 +434,19 @@ public function unlock( */ public function update( Ticket $ticket, - UpdateRequest $request - ): JsonResponse|RedirectResponse|TicketResource { + Requests\Ticket\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Ticket { + $validated = $request->validated(); $user = $request->user(); + $ticket->modified_by_id = $user?->id; + $ticket->update($validated); if ($request->expectsJson()) { - return (new TicketResource($ticket))->response($request); + return (new Resources\Ticket($ticket))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -447,40 +457,4 @@ public function update( return redirect(route('playground.matrix.resource.tickets.show', ['ticket' => $ticket->id])); } - - protected function getProjectKey(Ticket $ticket): string - { - $key = config('playground-matrix-resource.default_key'); - $key = is_string($key) ? $key : ''; - - $project = $ticket->project_id ? $ticket->project()->first() : null; - - if (! empty($project->key) && is_string($project->key)) { - $key = $project->key; - } - - return $key; - } - - protected function handleTicketCode(Ticket $ticket): void - { - if (empty($ticket->project_id)) { - return; - } - - $ticket->key = $this->getProjectKey($ticket); - - $code = Ticket::where('key', 'LIKE', $ticket->key)->max('code'); - $next = $code > 0 ? ++$code : 1; - $slug = sprintf( - '%1$s%2$s%3$d', - $ticket->key, - $ticket->key ? '-' : '', - $next - ); - - $ticket->code = $next; - $ticket->slug = $slug; - $ticket->key_code_hash = md5($slug); - } } diff --git a/src/Http/Controllers/VersionController.php b/src/Http/Controllers/VersionController.php index babc3ab..24b08e4 100644 --- a/src/Http/Controllers/VersionController.php +++ b/src/Http/Controllers/VersionController.php @@ -1,9 +1,9 @@ */ public array $packageInfo = [ - 'model_attribute' => 'label', + 'model_attribute' => 'title', 'model_label' => 'Version', 'model_label_plural' => 'Versions', 'model_route' => 'playground.matrix.resource.versions', @@ -50,19 +40,26 @@ class VersionController extends Controller ]; /** - * CREATE the Version resource in storage. + * Create the Version resource in storage. * * @route GET /resource/matrix/versions/create playground.matrix.resource.versions.create */ public function create( - CreateRequest $request - ): JsonResponse|View { + Requests\Version\CreateRequest $request + ): JsonResponse|View|Resources\Version { + $validated = $request->validated(); $user = $request->user(); $version = new Version($validated); + if ($request->expectsJson()) { + return (new Resources\Version($version))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + $meta = [ 'session_user_id' => $user?->id, 'id' => null, @@ -80,10 +77,6 @@ public function create( '_method' => 'post', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - $flash = $version->toArray(); if (! empty($validated['_return_url'])) { @@ -95,10 +88,7 @@ public function create( session()->flashInput($flash); } - return view( - 'playground-matrix-resource::version/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -108,12 +98,26 @@ public function create( */ public function edit( Version $version, - EditRequest $request - ): JsonResponse|View { + Requests\Version\EditRequest $request + ): JsonResponse|View|Resources\Version { + $validated = $request->validated(); $user = $request->user(); + if ($request->expectsJson()) { + return (new Resources\Version($version))->additional(['meta' => [ + 'info' => $this->packageInfo, + ]])->response($request); + } + + $flash = $version->toArray(); + + if (! empty($validated['_return_url'])) { + $flash['_return_url'] = $validated['_return_url']; + $data['_return_url'] = $validated['_return_url']; + } + $meta = [ 'session_user_id' => $user?->id, 'id' => $version->id, @@ -131,23 +135,9 @@ public function edit( '_method' => 'patch', ]; - if ($request->expectsJson()) { - return response()->json($data); - } - - $flash = $version->toArray(); - - if (! empty($validated['_return_url'])) { - $flash['_return_url'] = $validated['_return_url']; - $data['_return_url'] = $validated['_return_url']; - } - session()->flashInput($flash); - return view( - 'playground-matrix-resource::version/form', - $data - ); + return view(sprintf('%1$s/form', $this->packageInfo['view']), $data); } /** @@ -157,8 +147,9 @@ public function edit( */ public function destroy( Version $version, - DestroyRequest $request + Requests\Version\DestroyRequest $request ): Response|RedirectResponse { + $validated = $request->validated(); if (empty($validated['force'])) { @@ -177,7 +168,7 @@ public function destroy( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions')); + return redirect(route($this->packageInfo['model_route'])); } /** @@ -187,13 +178,14 @@ public function destroy( */ public function lock( Version $version, - LockRequest $request - ): JsonResponse|RedirectResponse|VersionResource { + Requests\Version\LockRequest $request + ): JsonResponse|RedirectResponse|Resources\Version { + $validated = $request->validated(); $user = $request->user(); - $version->setAttribute('locked', true); + $version->locked = true; $version->save(); @@ -205,7 +197,7 @@ public function lock( ]; if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -214,7 +206,10 @@ public function lock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions.show', ['version' => $version->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['version' => $version->id])); } /** @@ -223,8 +218,9 @@ public function lock( * @route GET /resource/matrix playground.matrix.resource.versions */ public function index( - IndexRequest $request - ): JsonResponse|View { + Requests\Version\IndexRequest $request + ): JsonResponse|View|Resources\VersionCollection { + $user = $request->user(); $validated = $request->validated(); @@ -234,6 +230,7 @@ public function index( $query->sort($validated['sort'] ?? null); if (! empty($validated['filter']) && is_array($validated['filter'])) { + $query->filterTrash($validated['filter']['trash'] ?? null); $query->filterIds( @@ -258,12 +255,12 @@ public function index( } $perPage = ! empty($validated['perPage']) && is_int($validated['perPage']) ? $validated['perPage'] : null; - $paginator = $query->paginate( $perPage); + $paginator = $query->paginate($perPage); $paginator->appends($validated); if ($request->expectsJson()) { - return (new VersionCollection($paginator))->response($request); + return (new Resources\VersionCollection($paginator))->response($request); } $meta = [ @@ -284,10 +281,7 @@ public function index( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::version/index', - $data - ); + return view(sprintf('%1$s/index', $this->packageInfo['view']), $data); } /** @@ -297,8 +291,9 @@ public function index( */ public function restore( Version $version, - RestoreRequest $request - ): JsonResponse|RedirectResponse|VersionResource { + Requests\Version\RestoreRequest $request + ): JsonResponse|RedirectResponse|Resources\Version { + $validated = $request->validated(); $user = $request->user(); @@ -306,7 +301,7 @@ public function restore( $version->restore(); if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -315,7 +310,10 @@ public function restore( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions.show', ['version' => $version->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['version' => $version->id])); } /** @@ -325,8 +323,9 @@ public function restore( */ public function show( Version $version, - ShowRequest $request - ): JsonResponse|View|VersionResource { + Requests\Version\ShowRequest $request + ): JsonResponse|View|Resources\Version { + $validated = $request->validated(); $user = $request->user(); @@ -340,7 +339,7 @@ public function show( ]; if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $meta['input'] = $request->input(); @@ -351,10 +350,7 @@ public function show( 'meta' => $meta, ]; - return view( - 'playground-matrix-resource::version/detail', - $data - ); + return view(sprintf('%1$s/detail', $this->packageInfo['view']), $data); } /** @@ -363,8 +359,9 @@ public function show( * @route POST /resource/matrix playground.matrix.resource.versions.post */ public function store( - StoreRequest $request - ): Response|JsonResponse|RedirectResponse|VersionResource { + Requests\Version\StoreRequest $request + ): Response|JsonResponse|RedirectResponse|Resources\Version { + $validated = $request->validated(); $user = $request->user(); @@ -374,7 +371,7 @@ public function store( $version->save(); if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -383,7 +380,10 @@ public function store( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions.show', ['version' => $version->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['version' => $version->id])); } /** @@ -393,18 +393,19 @@ public function store( */ public function unlock( Version $version, - UnlockRequest $request - ): JsonResponse|RedirectResponse|VersionResource { + Requests\Version\UnlockRequest $request + ): JsonResponse|RedirectResponse|Resources\Version { + $validated = $request->validated(); $user = $request->user(); - $version->setAttribute('locked', false); + $version->locked = false; $version->save(); if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -413,7 +414,10 @@ public function unlock( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions.show', ['version' => $version->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['version' => $version->id])); } /** @@ -423,8 +427,9 @@ public function unlock( */ public function update( Version $version, - UpdateRequest $request - ): JsonResponse|RedirectResponse|VersionResource { + Requests\Version\UpdateRequest $request + ): JsonResponse|RedirectResponse|Resources\Version { + $validated = $request->validated(); $user = $request->user(); @@ -432,7 +437,7 @@ public function update( $version->update($validated); if ($request->expectsJson()) { - return (new VersionResource($version))->response($request); + return (new Resources\Version($version))->response($request); } $returnUrl = $validated['_return_url'] ?? ''; @@ -441,6 +446,9 @@ public function update( return redirect($returnUrl); } - return redirect(route('playground.matrix.resource.versions.show', ['version' => $version->id])); + return redirect(route(sprintf( + '%1$s.show', + $this->packageInfo['model_route'] + ), ['version' => $version->id])); } } diff --git a/src/Http/Resources/Backlog.php b/src/Http/Resources/Backlog.php index 4703c07..c9b8aba 100644 --- a/src/Http/Resources/Backlog.php +++ b/src/Http/Resources/Backlog.php @@ -17,16 +17,6 @@ */ class Backlog extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/BacklogCollection.php b/src/Http/Resources/BacklogCollection.php index 4be8b47..515e3b6 100644 --- a/src/Http/Resources/BacklogCollection.php +++ b/src/Http/Resources/BacklogCollection.php @@ -16,16 +16,6 @@ */ class BacklogCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Board.php b/src/Http/Resources/Board.php index b971aae..617def3 100644 --- a/src/Http/Resources/Board.php +++ b/src/Http/Resources/Board.php @@ -14,16 +14,6 @@ class Board extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/BoardCollection.php b/src/Http/Resources/BoardCollection.php index f08db91..b563d66 100644 --- a/src/Http/Resources/BoardCollection.php +++ b/src/Http/Resources/BoardCollection.php @@ -13,16 +13,6 @@ class BoardCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Epic.php b/src/Http/Resources/Epic.php index 06cbf14..c931a9f 100644 --- a/src/Http/Resources/Epic.php +++ b/src/Http/Resources/Epic.php @@ -11,16 +11,6 @@ class Epic extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/EpicCollection.php b/src/Http/Resources/EpicCollection.php index 687d23a..98ca8a1 100644 --- a/src/Http/Resources/EpicCollection.php +++ b/src/Http/Resources/EpicCollection.php @@ -10,16 +10,6 @@ class EpicCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Flow.php b/src/Http/Resources/Flow.php index b3a8d50..a515d19 100644 --- a/src/Http/Resources/Flow.php +++ b/src/Http/Resources/Flow.php @@ -11,16 +11,6 @@ class Flow extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/FlowCollection.php b/src/Http/Resources/FlowCollection.php index 8e4a37a..ee012fd 100644 --- a/src/Http/Resources/FlowCollection.php +++ b/src/Http/Resources/FlowCollection.php @@ -10,16 +10,6 @@ class FlowCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Matrix.php b/src/Http/Resources/Matrix.php index e82aabc..4c01668 100644 --- a/src/Http/Resources/Matrix.php +++ b/src/Http/Resources/Matrix.php @@ -14,16 +14,6 @@ class Matrix extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/MatrixCollection.php b/src/Http/Resources/MatrixCollection.php index 026ffcb..9abfcf1 100644 --- a/src/Http/Resources/MatrixCollection.php +++ b/src/Http/Resources/MatrixCollection.php @@ -13,16 +13,6 @@ class MatrixCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Milestone.php b/src/Http/Resources/Milestone.php index 61d4c47..2fe4e02 100644 --- a/src/Http/Resources/Milestone.php +++ b/src/Http/Resources/Milestone.php @@ -11,16 +11,6 @@ class Milestone extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/MilestoneCollection.php b/src/Http/Resources/MilestoneCollection.php index 0a727eb..54f6e39 100644 --- a/src/Http/Resources/MilestoneCollection.php +++ b/src/Http/Resources/MilestoneCollection.php @@ -10,16 +10,6 @@ class MilestoneCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Note.php b/src/Http/Resources/Note.php index ea2f5b1..307c52f 100644 --- a/src/Http/Resources/Note.php +++ b/src/Http/Resources/Note.php @@ -14,16 +14,6 @@ class Note extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/NoteCollection.php b/src/Http/Resources/NoteCollection.php index faa7aeb..2658fe1 100644 --- a/src/Http/Resources/NoteCollection.php +++ b/src/Http/Resources/NoteCollection.php @@ -13,16 +13,6 @@ class NoteCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Project.php b/src/Http/Resources/Project.php index 33209a9..10fb02d 100644 --- a/src/Http/Resources/Project.php +++ b/src/Http/Resources/Project.php @@ -14,16 +14,6 @@ class Project extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/ProjectCollection.php b/src/Http/Resources/ProjectCollection.php index a7ff829..24ee50e 100644 --- a/src/Http/Resources/ProjectCollection.php +++ b/src/Http/Resources/ProjectCollection.php @@ -13,16 +13,6 @@ class ProjectCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Release.php b/src/Http/Resources/Release.php index a1699e9..07c1828 100644 --- a/src/Http/Resources/Release.php +++ b/src/Http/Resources/Release.php @@ -14,16 +14,6 @@ class Release extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/ReleaseCollection.php b/src/Http/Resources/ReleaseCollection.php index e71cbe8..17a740a 100644 --- a/src/Http/Resources/ReleaseCollection.php +++ b/src/Http/Resources/ReleaseCollection.php @@ -13,16 +13,6 @@ class ReleaseCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Roadmap.php b/src/Http/Resources/Roadmap.php index 3bfe25d..93bf1d8 100644 --- a/src/Http/Resources/Roadmap.php +++ b/src/Http/Resources/Roadmap.php @@ -14,16 +14,6 @@ class Roadmap extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/RoadmapCollection.php b/src/Http/Resources/RoadmapCollection.php index 7b343bd..8db521d 100644 --- a/src/Http/Resources/RoadmapCollection.php +++ b/src/Http/Resources/RoadmapCollection.php @@ -13,16 +13,6 @@ class RoadmapCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Source.php b/src/Http/Resources/Source.php index 36514c8..e025ec9 100644 --- a/src/Http/Resources/Source.php +++ b/src/Http/Resources/Source.php @@ -14,16 +14,6 @@ class Source extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/SourceCollection.php b/src/Http/Resources/SourceCollection.php index 1e6cfb0..dde5093 100644 --- a/src/Http/Resources/SourceCollection.php +++ b/src/Http/Resources/SourceCollection.php @@ -13,16 +13,6 @@ class SourceCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Sprint.php b/src/Http/Resources/Sprint.php index 259e4f9..0db6dc2 100644 --- a/src/Http/Resources/Sprint.php +++ b/src/Http/Resources/Sprint.php @@ -14,16 +14,6 @@ class Sprint extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/SprintCollection.php b/src/Http/Resources/SprintCollection.php index 981eea3..8303b77 100644 --- a/src/Http/Resources/SprintCollection.php +++ b/src/Http/Resources/SprintCollection.php @@ -13,16 +13,6 @@ class SprintCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Tag.php b/src/Http/Resources/Tag.php index a58642d..8a8e5e6 100644 --- a/src/Http/Resources/Tag.php +++ b/src/Http/Resources/Tag.php @@ -14,16 +14,6 @@ class Tag extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/TagCollection.php b/src/Http/Resources/TagCollection.php index b0c8330..5bf5c99 100644 --- a/src/Http/Resources/TagCollection.php +++ b/src/Http/Resources/TagCollection.php @@ -13,16 +13,6 @@ class TagCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Team.php b/src/Http/Resources/Team.php index cda276e..6788098 100644 --- a/src/Http/Resources/Team.php +++ b/src/Http/Resources/Team.php @@ -14,16 +14,6 @@ class Team extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/TeamCollection.php b/src/Http/Resources/TeamCollection.php index 62848dc..6ae9252 100644 --- a/src/Http/Resources/TeamCollection.php +++ b/src/Http/Resources/TeamCollection.php @@ -13,16 +13,6 @@ class TeamCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Ticket.php b/src/Http/Resources/Ticket.php index 035fc56..37c24cc 100644 --- a/src/Http/Resources/Ticket.php +++ b/src/Http/Resources/Ticket.php @@ -14,16 +14,6 @@ class Ticket extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/TicketCollection.php b/src/Http/Resources/TicketCollection.php index 9103fd0..ceff396 100644 --- a/src/Http/Resources/TicketCollection.php +++ b/src/Http/Resources/TicketCollection.php @@ -13,16 +13,6 @@ class TicketCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/Version.php b/src/Http/Resources/Version.php index cd9a2ce..e0f3572 100644 --- a/src/Http/Resources/Version.php +++ b/src/Http/Resources/Version.php @@ -14,16 +14,6 @@ class Version extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. * diff --git a/src/Http/Resources/VersionCollection.php b/src/Http/Resources/VersionCollection.php index 0932a89..a031fe6 100644 --- a/src/Http/Resources/VersionCollection.php +++ b/src/Http/Resources/VersionCollection.php @@ -13,16 +13,6 @@ class VersionCollection extends ResourceCollection { - /** - * Transform the resource collection into an array. - * - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray(Request $request) - { - return parent::toArray($request); - } - /** * Get additional data that should be returned with the resource array. *