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

boyjarv's avatar

"message": "No query results for model [App\\Venue] stats",

When I run my URL using GET: moveme.test/venues/1152522/tagin/stats in postman, I get the following message:

"message": "No query results for model [App\Venue] stats",

Here is my method, nothing gets output to the screen

public function venueTaginstats($id) {
        $tagins = Tagin::findOrFail($id);
        dd($tagins);
//        return view('venues.tagins', compact(
//            'tagins'));
    }
0 likes
12 replies
Sinnbeck's avatar

Can you show the route?

And I assume 1152522 is the id?

If that id does not exist, it will throw an exception. That is what findOrFail does. Use find() instead if you don't want the error

boyjarv's avatar

yes thats the ID of the actual venue not the TAGIN (model) ID

here is my route:

Route::get('/venues/{id}/tagin/stats', 'VenueController@venueTaginstats')->name('venue.venuetaginstats');

I have 2 tables TAGINS - phone_number, venue_id, .... VENUES - id, venueName....

I have a relationship setup on these in their model files

Sinnbeck's avatar

Then why are you using it to find a tagin?


$venue = Venue::findOrFail($id);
$venue->load('tagins') ;
$tagins = $venue->tagins;
boyjarv's avatar

nope, still the same and 404 not found?!

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Are you sure that the id exists?

$venue = Venue::find($id);
dd($venue);
boyjarv's avatar

I'm not getting anything?! still 404 and same error in postman

 public function venueTaginstats($id) {
        $venue = Venue::find($id);
        $tagins = Venue::findOrFail($id)->tagins;
        dd($venue);
        return view('venues.tagins', compact(
            'tagins'));
    }

Sinnbeck's avatar

Yes.. Remove this line

$tagins = Venue::findOrFail($id)->tagins;
boyjarv's avatar

nope still nothing, I want to get all tagins for the venue I am currently looking at

boyjarv's avatar

I don't think it's actually getting to the method?!

boyjarv's avatar

git it now thanks! I had to move my route up the list., not sure why?!

Sinnbeck's avatar

That would be because laravel works by first match. So lets say you have another route that could match, higher up in the routes file.

Example.

Route::get('/venues/{id}/tagin/{tagId}', 'TagController@someMethod');
Route::get('/venues/{id}/tagin/stats', 'VenueController@venueTaginstats')->name('venue.venuetaginstats');

There the urlm path /venues/1152522/tagin/stats will actually match the first route, as laravel does not know if {tagId} is an integer or a word.. So it matches it to 'stats'

Please or to participate in this conversation.