Reputation: 18410
Here's my controller code:
public function update(Request $request, $id)
{
$currency = Currency::find($id);
$this->validate($request, [
'cur_name' => 'required',
'cur_price' => 'required|numeric',
'cur_icon' => 'required|image|max:100',
'cur_reserve' => 'required|numeric',
]);
$currency->cur_name = strip_tags($request->input('cur_name'));
$currency->cur_price = $request->input('cur_price');
// image
$file = $request->file('cur_icon');
if (isset($file)) {
$filename = Str::lower(
pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . uniqid() . '.' . $file->getClientOriginalExtension()
);
$destination = 'uploads/';
$file->move($destination, $filename);
$currency->cur_icon = $filename;
}
$currency->cur_reserve = $request->input('cur_reserve');
$currency->slug = \Slug::make(strip_tags($request->input('cur_name')));
dd($currency);
$currency->save();
return redirect('/admin/currency');
}
edit.blade.php (short):
<form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="/admin/currency/{{ $currency->id }}">
{{ csrf_field() }}
<input name="_method" type="hidden" value="PUT">
...
</form>
routes:
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function() {
Route::resource('currency', 'CurrencyController');
});
When i click on submit - i am not being redirected and nothing happens, just page reloads - that's all. Even if i modify data no changes are saved to database.
Upvotes: 0
Views: 913
Reputation: 1
Include something like:
protected $fillable = [
'name', 'email', 'password',
'gender', 'phone' ,'isActive',
'photo','setup', 'address'
];
In your Model
Upvotes: 0
Reputation: 6345
If you aren't getting to dd($currency);
before $currency->save()
? then it may be the validator redirecting. Try debugging with this in your view to check:
{{ count($errors) > 0 ? dd($errors->all()) : ''}}
Upvotes: 3
Reputation: 697
Try this, you need to use url() method to get full url.
action="{{ url('/admin/currency/' . $currency->id) }}">
Upvotes: 1