32 lines
843 B
PHP
32 lines
843 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\ManageBrandRequest;
|
|
use App\Models\Brand;
|
|
use Illuminate\Http\Request;
|
|
|
|
class BrandController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$brands = Brand::all();
|
|
return view('brands.index', compact('brands'));
|
|
}
|
|
|
|
public function manage(ManageBrandRequest $request, Brand $brand)
|
|
{
|
|
if ($request->isMethod('post')) {
|
|
if (!$brand) {
|
|
$brand = new Brand($request->validated());
|
|
} else {
|
|
$brand->fill($request->validated());
|
|
}
|
|
$brand->save();
|
|
return redirect()->route('brands')->with('success', trans('Modifications enregistrées !'));
|
|
}
|
|
|
|
return view('brands.manage', compact('brand'));
|
|
}
|
|
}
|