Tuesday, March 7, 2017

Display data based on select Laravel

So, someone wants to give me a downvote without a reason. Thanks for nothing

I am trying to display some data based on a select value. The select options are populated by

user->firstName

in my table i also have a column "role" I want to display the users role based on the selected user. How would i achieve this?

index method on UserController

public function index()
{
    //
    $data = User::paginate(10);
    return view('user.dashboard')->with("users", $data);
}

The front-end

<div class="panel panel-warning">
    <div class="panel-heading">
        <p>Returning a specific users role</p>
        <select>
            @foreach ($users as $user)
            <option></option>
            @endforeach
        </select>
    </div>
    <div class="panel-body">

        <p>This users role is:</p>
    </div>
</div>

How would i display the selected users role? or get to change depending on the selected option.



via Jay240692

Advertisement