dimanche 5 mai 2019

In create view search by "ID"

I'm beginner in Laravel, how can I redirect from create view to edit view when entered ID in input text field?

Tried by following code but not getting any ID in URL.

Controller:

use Illuminate\Support\Facades\Input;

public function edit(visitor $visitor)
    {
        $visitors= visitor::all();
        $find = Input::get('find');
        visitor::where('id', 'LIKE', '%' . $find . '%')->get();
        return view('create', compact('visitors'));
    }

View:

<form method="post" action="" class="form-group>
@csrf
@foreach($visitors as $visitor)
<label for="visitor">Visitor No:</label>
<a href=""> 
@endforeach
<input type="text" name="find" class="form-control" value="">

// $newvisitnum is my auto increment ID //

Getting error of "Undefined variable: visitors

In URL it should appear like this "visitors/{id}/edit" and should fetch all records to edit view associated with that ID.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire