🚧 Corrige la mise à jour

This commit is contained in:
Clement Desmidt 2017-11-20 23:29:57 +01:00
parent eda18e25e8
commit 92dc6f33f9
3 changed files with 8 additions and 9 deletions

View File

@ -65,7 +65,7 @@ class HomeController extends Controller
->setBody($request->body)
->setCategory($request->category)
->setPrice($request->price)
->save($folder_path);
->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 view('update', ['deal' => $deal, 'type' => $type]);

View File

@ -14,19 +14,20 @@
</div>
@endif
<form method="post">
{{ csrf_field() }}
<label for="subject">Sujet : </label>
<input type="text" id="subject" name="subject" value="{{ $deal->getSubject() }}" />
<input type="text" id="subject" name="subject" value="{{ $deal->getSubject() }}" /><br>
<label for="body">Description : </label>
<textarea id="body" name="body">{{ $deal->getBody() }}</textarea>
<textarea id="body" name="body">{{ $deal->getBody() }}</textarea><br>
<label for="price">Prix : </label>
<input type="text" id="price" name="price" value="{{ $deal->getPrice() }}" />
<input type="text" id="price" name="price" value="{{ $deal->getPrice() }}" /><br>
<label for="category">Catégorie : </label>
<select id="category" name="category">
<option value=""></option>
@foreach(\Shikiryu\LBCReposter\Categories::$categories as $id => $category)
<<option value="{{ $id }}"{{ $deal->getCategory() === $id ? ' selected="selected"': '' }}>{{ $category }}</option>
<<option value="{{ $id }}" @if( $deal->getCategory() === $category ) selected="selected" @endif>{{ $category }}</option>
@endforeach
</select>
</select><br>
<input type="submit" value="Modifier" />
</form>
</div>

View File

@ -23,6 +23,4 @@ Route::get('/deals/view/{type}/{id}', 'HomeController@view')->name('deals.view')
Route::get('/deals/delete/{type}/{id}', 'HomeController@delete')->name('deals.delete');
Route::get('/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update');
Route::post('/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update.post');
Route::match(['GET', 'POST'], '/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update');