Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
Override screen handle to fix save method params
Browse files Browse the repository at this point in the history
Used the workaround proposed in this [PR](orchidsoftware/platform#2299)
  • Loading branch information
jgarivera committed Sep 10, 2022
1 parent 2041bc5 commit 142a21a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/Orchid/Screens/Batch/BatchSeedAllocationEditScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
use App\Models\Batch\BatchSeedAllocation;
use App\Orchid\Layouts\Batch\BatchSeedAllocationEditLayout;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Route;
use Orchid\Screen\Actions\Button;
use Orchid\Screen\Screen;
use Orchid\Support\Facades\Dashboard;
use Orchid\Support\Facades\Layout;

class BatchSeedAllocationEditScreen extends Screen
Expand All @@ -22,6 +25,34 @@ public function __construct()
$this->description = __('Create a new batch seed allocation');
}

public function handle(Request $request, ...$parameters)
{
Dashboard::setCurrentScreen($this);

abort_unless($this->checkAccess($request), 403);

if ($request->isMethod('GET')) {
return $this->redirectOnGetMethodCallOrShowView($parameters);
}

$method = Route::current()->parameter('method', Arr::last($parameters));

$prepare = collect($parameters)
->merge($request->query())
->diff($method)
->all();

return $this->callMethod($method, $prepare) ?? back();
}

private function callMethod(string $method, array $parameters = [])
{
return call_user_func_array(
[$this, $method],
$this->resolveDependencies($method, $parameters)
);
}

/**
* Query data.
*
Expand Down

0 comments on commit 142a21a

Please sign in to comment.