Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gammamatrix committed May 21, 2024
1 parent 24a3b23 commit 10e04b9
Show file tree
Hide file tree
Showing 51 changed files with 1,041 additions and 1,294 deletions.
1 change: 0 additions & 1 deletion config/playground-matrix-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ parameters:

treatPhpDocTypesAsCertain: false

checkGenericClassInNonGenericObjectType: false

# editorUrl: 'vscode://file/%%file%%:%%line%%'
# editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
42 changes: 23 additions & 19 deletions src/Http/Controllers/BacklogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BacklogController extends Controller
* @var array<string, string>
*/
public array $packageInfo = [
'model_attribute' => 'label',
'model_attribute' => 'title',
'model_label' => 'Backlog',
'model_label_plural' => 'Backlogs',
'model_route' => 'playground.matrix.resource.backlogs',
Expand All @@ -40,20 +40,26 @@ 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();

$user = $request->user();

$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,
Expand All @@ -71,10 +77,6 @@ public function create(
'_method' => 'post',
];

if ($request->expectsJson()) {
return response()->json($data);
}

$flash = $backlog->toArray();

if (! empty($validated['_return_url'])) {
Expand All @@ -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,
Expand All @@ -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);
Expand Down
42 changes: 23 additions & 19 deletions src/Http/Controllers/BoardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BoardController extends Controller
* @var array<string, string>
*/
public array $packageInfo = [
'model_attribute' => 'label',
'model_attribute' => 'title',
'model_label' => 'Board',
'model_label_plural' => 'Boards',
'model_route' => 'playground.matrix.resource.boards',
Expand All @@ -40,20 +40,26 @@ 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();

$user = $request->user();

$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,
Expand All @@ -71,10 +77,6 @@ public function create(
'_method' => 'post',
];

if ($request->expectsJson()) {
return response()->json($data);
}

$flash = $board->toArray();

if (! empty($validated['_return_url'])) {
Expand All @@ -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,
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 10e04b9

Please sign in to comment.