Support the ongoing development of Laravel.io →
Eloquent Database
Last updated 2 years ago.
0
moderator

Can you explain how it fails? The first impression is that this looks good.

0

Thank you for your reply I submit these screen-shots to show you

my question is App\Dog::all(); // all() function is build-in // not needed declare???

SCREENSHOT-1: https://yadi.sk/i/YdMOwZ-b0NX_8Q

SCREENSHOT-2: https://yadi.sk/i/Rd90g7yrm1WP-w

0
moderator Solution

Thanks for the screenshots, they made it clear.

You can use Dog::all(); (because you have the use statement) or \App\Dog:all();

Your controller lives in the App\Http\Controllers namespace with App\Dog(); it search for the class App\Http\Controllers\App\Dog and that class doesn't exist. That is because of the missing \ in front of it.

0

Thank you - now working 1st way $dogs = \App\Dog::all();

    foreach ($dogs as $dog) {
        echo $dog->name;
    }

2nd way $dogs = Dog::all(); // use \App\Dog; // on top

0

http://homestead.test/dog GET // THIS GET ok get the result

http://homestead.test/dog POST // THIS GET : // ERROR IN POSTMAN App cannot call function: store in controller

any hint to try???

<body> <div class="flex-center position-ref full-height"> <div class="code"> 419 </div>
	<div class="message" style="padding: 10px;">
		Page Expired </div>
</div>
</body> </html> | | GET|HEAD | dog | dog.index | App\Http\Controllers\DogController@index | web | | | POST | dog | dog.store | App\Http\Controllers\DogController@store | web | | | GET|HEAD | dog/create | dog.create | App\Http\Controllers\DogController@create | web |
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.