style updates
This commit is contained in:
@@ -10,18 +10,51 @@ use Modules\Testimonials\Models\Testimonial;
|
||||
|
||||
final class TestimonialController extends Controller
|
||||
{
|
||||
public function index(): View { return view('testimonials::admin.index', ['records' => Testimonial::query()->latest()->paginate(20)]); }
|
||||
public function create(): View { return view('testimonials::admin.form'); }
|
||||
public function store(Request $request): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
public function index(): View
|
||||
{
|
||||
return view('testimonials::admin.index', ['records' => Testimonial::query()->latest()->paginate(20)]);
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
return view('testimonials::admin.form');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'company' => ['nullable', 'string'],
|
||||
'content' => ['required', 'string'],
|
||||
'rating' => ['nullable', 'integer', 'min:0'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); Testimonial::create($data); return redirect()->route('testimonials.index')->with('status', 'Testimonial created.'); }
|
||||
public function edit(Testimonial $testimonial): View { return view('testimonials::admin.form', ['record' => $testimonial]); }
|
||||
public function update(Request $request, Testimonial $testimonial): RedirectResponse { $data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
Testimonial::create($data);
|
||||
|
||||
return redirect()->route('testimonials.index')->with('status', 'Testimonial created.');
|
||||
}
|
||||
|
||||
public function edit(Testimonial $testimonial): View
|
||||
{
|
||||
return view('testimonials::admin.form', ['record' => $testimonial]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Testimonial $testimonial): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['name' => ['required', 'string', 'max:255'],
|
||||
'company' => ['nullable', 'string'],
|
||||
'content' => ['required', 'string'],
|
||||
'rating' => ['nullable', 'integer', 'min:0'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); $testimonial->update($data); return redirect()->route('testimonials.index')->with('status', 'Testimonial updated.'); }
|
||||
public function destroy(Testimonial $testimonial): RedirectResponse { $testimonial->delete(); return back()->with('status', 'Testimonial deleted.'); }
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
$testimonial->update($data);
|
||||
|
||||
return redirect()->route('testimonials.index')->with('status', 'Testimonial updated.');
|
||||
}
|
||||
|
||||
public function destroy(Testimonial $testimonial): RedirectResponse
|
||||
{
|
||||
$testimonial->delete();
|
||||
|
||||
return back()->with('status', 'Testimonial deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user