Now i show you how tu update your record now you must add route someone show your form to update record
thats looks like this:
Route::get('/{id}/edit', 'Posts\LibraryController@edit')->name('update');
Route::put('/{id}/edit', 'Posts\LibraryController@update')->name('edit');
in get we have id our column record someone we change the method put we change our record
in controller looks like this:
public function edit($id)
{
$lib = Car::findOrfail($id);
return view('library.edit', compact('lib'));
}
public function update(Request $request, $id)
{
$lib = Car::find($id);
$lib->model = $request->model;
$lib->save();
}
firs location to our form with id someone we choose the func update we just change our record
In view look like this:
{{ Form::open(['route' => ['edit',$lib->id], 'method' => 'PUT'])}}
{{Form::text('model', $lib->model)}}
{{Form::submit('Click Me!')}}
{!! Form::close() !!}
and all if you want read someone record its a that same method just you dont need form of course if you need
the remove record look like
this in controller:
public function destroy($id)
{
$lib = Car::find($id);
$lib->delete();
return redirect()->back();
}
in route:
Route::delete('/homelibrary/{id}', 'Posts\LibraryController@destroy')->name('remove');
in view
@foreach( $library as $libs)
{{ $libs->model}}
Read record
edytuj record
{{ Form::open(['route' => ['remove', $libs->id], 'method' => 'DELETE'])}}
{{Form::submit('Remove this record!')}}
{!! Form::close() !!}
@endforeach
Dodaj record
My video is at DLive