Answer the question
In order to leave comments, you need to log in
Laravel does not find the model class. How to fix?
The bottom line is this: I created a model using php artisan make:model Models\Game
Then I created the following service provider:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GameServiceProvider extends ServiceProvider
{
protected $defer = true;
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('Game', function($app)
{
return new \App\Models\Game();
});
}
public function provides()
{
return ['\App\Models\Game'];
}
}
App\Providers\GameServiceProvider::class
Route::get('/', function () {
$games=(new \app\models\Game())->all();
return view('main',['games'=>$games]);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question