Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daniel21gt's avatar

problem with query where select

I have tried to do a where query with a select options

Code with error

https://paste.laravel.io/de1569e9-6fe5-477c-b6fc-eac5fb3d59d9

"Trying to get property of non-object (View: C:\laragon\www\crudgobernaciontres\resources\views\Usuario\index.blade.php)"

In this module I consult all the records, but I also want to select by username, I still do not get it.

view https://paste.laravel.io/505fad0a-3fb6-49d4-9465-1751e9de6136 controller https://paste.laravel.io/dfdbb2b5-8c9f-46b2-b9bc-38b5dc2a7cbe

Is it possible to do this in the same module?

0 likes
4 replies
bobbybouwmann's avatar

This seems to be invalid

<form action="{{route('usuario.show', $id->$usuario_ad)}}" method="POST">

Note the $id->$usuario_ad. I think you need one of the parameters here instead of both!

Snapey's avatar

Not sure what you are trying to do but your loop will not produce valid html

bobbybouwmann's avatar

Your form fields always need to be inside the <form> and </form> tags. Otherwise your browser doesn't understand how to post it. After that you should be able to get it from the request.

Note that you can't post to a get route. In this case the show route is already a get route and you can't combine the two. Instead you can use a query parameter in your url to do the filter

<form method="GET" action="{{ route('usuario.show', $id) }}">

    // Your select here
    // Your submit button here

</form>

// In your controller you can access the filter like so
public function show(Request $request, $id)
{
    $filter = $request->get('tipo');

    // your query with above filter

    // The response here
}

Please or to participate in this conversation.