I want to create a page for admin where the page is only used to display data and update data. I create a table in the database without using an ID, because I don't want to create new data and only want to have one data other than that it can update that data.
this is my route
Route::group(['prefix' => 'admin', 'middleware' => ['web']], function () {
Route::get('about', 'AboutController@index');
Route::post('about/update', 'AboutController@update');
});
this is my model
public $timestamps = false;
protected $primaryKey = null;
public $incrementing = false;
protected $fillable = ['description'];
this is my controller AboutController.php
public function index()
{
$data = About::first();
return view('config_about.index', compact('data'));
}
public function update(Request $request)
{
$this->validate($request, [
'description' => 'required'
]);
$data= About::first()->update($request->all());
return redirect('admin/about');
}
and this is my form
{!! Form::open(['url' => 'admin/about/update', 'method' => 'post', 'class' => 'form-horizontal']) !!}
<div class="form-group ">
<div class="col-md-12">
{!! Form::textarea('description', $data->description, ['class' => 'form-control']) !!}
{!! $errors->first('description', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-0">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
</div>
</div>
{!! Form::close() !!}
I hope the results can update the data but what I get is an error like This page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire