🍻 Remet en place la logique de maj

This commit is contained in:
Clement Desmidt 2017-11-20 15:29:48 +01:00
parent c52a163a55
commit eda18e25e8

View File

@ -58,12 +58,14 @@ class HomeController extends Controller
} }
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
// TODO filter // TODO filter
$deal $updated_deal = \Shikiryu\LBCReposter\Deal::fromJSON($folder_path . '/data.json');
->setSubject($request->subject) $result =
->setBody($request->body) $updated_deal
->setCategory($request->category) ->setSubject($request->subject)
->setPrice($request->price); ->setBody($request->body)
$deal->save($folder_path); ->setCategory($request->category)
->setPrice($request->price)
->save($folder_path);
return redirect()->route('deals.list', ['type' => $type])->with('status', ($result ? 'Deal mis à jour': 'ERREUR')); return redirect()->route('deals.list', ['type' => $type])->with('status', ($result ? 'Deal mis à jour': 'ERREUR'));
} }
return view('update', ['deal' => $deal, 'type' => $type]); return view('update', ['deal' => $deal, 'type' => $type]);