🚧 Corrige l'enregistrement des mises à jour
This commit is contained in:
parent
be5336fc13
commit
d4156ce3a3
@ -58,14 +58,22 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
if ($request->isMethod('post')) {
|
if ($request->isMethod('post')) {
|
||||||
// TODO filter
|
// TODO filter
|
||||||
$updated_deal = \Shikiryu\LBCReposter\Deal::fromJSON($folder_path . '/data.json');
|
|
||||||
|
$json_data = \json_decode(file_get_contents($folder_path . '/data.json'), true);
|
||||||
|
$json_data['subject'] = $request->subject;
|
||||||
|
$json_data['body'] = $request->body;
|
||||||
|
$json_data['category'] = $request->category;
|
||||||
|
$json_data['price'] = $request->price;
|
||||||
|
$result = file_put_contents($folder_path . '/data.json', \json_encode($json_data, JSON_UNESCAPED_UNICODE)) !== false;
|
||||||
|
// FIXME when API is updated
|
||||||
|
/*$updated_deal = \Shikiryu\LBCReposter\Deal::fromJSON($folder_path . '/data.json');
|
||||||
$result =
|
$result =
|
||||||
$updated_deal
|
$updated_deal
|
||||||
->setSubject($request->subject)
|
->setSubject($request->subject)
|
||||||
->setBody($request->body)
|
->setBody($request->body)
|
||||||
->setCategory($request->category)
|
->setCategory($request->category)
|
||||||
->setPrice($request->price)
|
->setPrice($request->price);
|
||||||
->save(sprintf('%s/%s', config('app.deals_dir'), $type), false);
|
->save(sprintf('%s/%s', config('app.deals_dir'), $type), false);*/
|
||||||
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]);
|
||||||
|
Loading…
Reference in New Issue
Block a user