Laravel: Error while recalling dropdown selected option

  dropdown, laravel, php

I’m just starting a project on php using laravel. I’m new to web development.

I’m trying to use a dropdown (with fixed values) to assign user role. On user’s first log in they will be prompted to select a role and I want to patch that into the database.
Woops, sorry for spanish in code (it’s for institutional purposes)

My view:

<div class="container">
<!--Inicio Dash-->
No tienes Rol!
    Selecciona un rol!
    <select name="lista-roles">
    <option value="coachs">Entrenador</option>
    <option value="coachees">Entrenado</option>
    <option value="pmanagers">Supervisor</option>

<a href="{{url('/usercontroller/'.Auth::user()->id.'/actrole/??????????')}}" class="btn btn-outline-primary">

The route:

Route::get('/usercontroller/{id}/actrole/{newrole}', '[email protected]');

The controller:

namespace AppHttpControllers;
use AppModelsUser;
use IlluminateHttpRequest;

class UserController extends Controller
public function actualizarrol($id,$newrole)
    User::where('id', $id)->update(['requested_role' => $role]);
    return redirect ('/');
    //return view('/');

I tryed passing the selected parameter on the route, but failed, so now as I read some Stackoverflow I’m trying to pick the information from the option list in the controller, but failing too.

The error reads: Request can’t be called statically

I’m sure I’m doing a dumb mistake, but since I’m too noob I can’t find out.
Thanks for the help!

Edit: Logic works perfect if I pass fixed values on the route like:


And using the $newrole parameter like:

public function actualizarrol($id,$newrole)
    User::where('id', $id)->update(['requested_role' => $newrole]);
    return redirect ('/');
    //return view('/');

Source: Laravel

Leave a Reply