I am a noob with laravel just picked it up today, what seems to be an easy task that looks lovable has caused a headache.
I am following a tutorial from Jeffery Way, and we seeded the database, the next step is to create a controller and get the resource. I generated the necessary files, then followed these basic steps.
The database table is 'players'
Step 1.
//Here is the index() function inside my PlayersController.php
class PlayersController extends \BaseController {
public function index()
{
return Player::all();
}
}
Step 2.
//Inside the app/models/ directory I create a file called Player.php
//Here is the code inside Player.php
class Player extends Eloquent {
protected $table = 'players' // I tried without the protect aswell
}
Step 3.
//Finially a route
Route::resource('players', 'PlayersController');
Route::get('/', function()
{
return View::make('hello');
});
For extra measure I also ran composer dump-autoload
in the command line, inside the root directory of my laravel project.
Then now I wasnt told which directory the route would be in, since it's an index function I assumed it's inside the root, so I have tried several url's
http://localhost/basketball-app-framework/public/players
http://localhost/basketball-app-framework/players
This last one would obviously only work if I pointed localhost to the public directory, I did do that however, still a no go. I am confused as ever.
http://localhost/players
I have tried a bunch other url's but those only are the ones that make sense, and the ones I am pretty sure should be working.
It blows I have to do some digging to figure out this simple mistake I am sure I am making, but whatever it takes to understand why I cant fetch that data from my database.