Skip to content

Commit

Permalink
Fix legacy settings in Twill 3 (#2417)
Browse files Browse the repository at this point in the history
* Fix legacy settings in Twill 3

* Add explicit View facade import

---------

Co-authored-by: Quentin Renard <[email protected]>
  • Loading branch information
joyceverheije and ifox authored Feb 4, 2024
1 parent c1fd952 commit 82bf2d8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Http/Controllers/Admin/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Facades\View;
use Illuminate\View\Factory as ViewFactory;

class SettingController extends Controller
Expand Down Expand Up @@ -61,18 +62,26 @@ public function __construct(
*/
public function index(string $section)
{
return $this->viewFactory->exists('twill.settings.' . $section)
? $this->viewFactory->make('twill.settings.' . $section, [
if (! $this->viewFactory->exists('twill.settings.' . $section)) {
return $this->redirector->back();
}

$formFields = $this->settings->getFormFieldsForSection($section);

View::share('form', [
'form_fields' => $formFields,
]);

return $this->viewFactory->make('twill.settings.' . $section, [
'customForm' => true,
'editableTitle' => false,
'customTitle' => ucfirst($section) . ' settings',
'section' => $section,
'form_fields' => $this->settings->getFormFieldsForSection($section),
'form_fields' => $formFields,
'formBuilder' => Form::make(),
'saveUrl' => $this->urlGenerator->route(config('twill.admin_route_name_prefix') . 'settings.update', $section),
'translate' => true,
])
: $this->redirector->back();
]);
}

/**
Expand Down

0 comments on commit 82bf2d8

Please sign in to comment.