style updates
This commit is contained in:
@@ -10,20 +10,57 @@ use Modules\Forms\Models\Form;
|
||||
|
||||
final class FormController extends Controller
|
||||
{
|
||||
public function index(): View { return view('forms::admin.index', ['records' => Form::query()->latest()->paginate(20)]); }
|
||||
public function create(): View { return view('forms::admin.form'); }
|
||||
public function store(Request $request): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
public function index(): View
|
||||
{
|
||||
return view('forms::admin.index', ['records' => Form::query()->latest()->paginate(20)]);
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
return view('forms::admin.form');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'schema' => ['nullable', 'array'],
|
||||
'enabled' => ['sometimes', 'boolean']]); if ($request->filled('schema_json')) { $data['schema'] = json_decode($request->string('schema_json')->toString(), true, 512, JSON_THROW_ON_ERROR); }
|
||||
$data['enabled'] = $request->boolean('enabled'); Form::create($data); return redirect()->route('forms.index')->with('status', 'Form created.'); }
|
||||
public function edit(Form $form): View { return view('forms::admin.form', ['record' => $form]); }
|
||||
public function update(Request $request, Form $form): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
if ($request->filled('schema_json')) {
|
||||
$data['schema'] = json_decode($request->string('schema_json')->toString(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
Form::create($data);
|
||||
|
||||
return redirect()->route('forms.index')->with('status', 'Form created.');
|
||||
}
|
||||
|
||||
public function edit(Form $form): View
|
||||
{
|
||||
return view('forms::admin.form', ['record' => $form]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Form $form): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'schema' => ['nullable', 'array'],
|
||||
'enabled' => ['sometimes', 'boolean']]); if ($request->filled('schema_json')) { $data['schema'] = json_decode($request->string('schema_json')->toString(), true, 512, JSON_THROW_ON_ERROR); }
|
||||
$data['enabled'] = $request->boolean('enabled'); $form->update($data); return redirect()->route('forms.index')->with('status', 'Form updated.'); }
|
||||
public function destroy(Form $form): RedirectResponse { $form->delete(); return back()->with('status', 'Form deleted.'); }
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
if ($request->filled('schema_json')) {
|
||||
$data['schema'] = json_decode($request->string('schema_json')->toString(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
$form->update($data);
|
||||
|
||||
return redirect()->route('forms.index')->with('status', 'Form updated.');
|
||||
}
|
||||
|
||||
public function destroy(Form $form): RedirectResponse
|
||||
{
|
||||
$form->delete();
|
||||
|
||||
return back()->with('status', 'Form deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user