php artisan make:migration create_students_table --create=students
Navigate to the database/migrations folder and select your file
Add the following lines to the code
$table->string('name');
$table->string('email');
$table->string('course');
Now that we have our DB structure setup let us run it by using the commands
php artisan migrate
In case of any problems ensure to have setup your DB as instructed here https://community.c9.io/t/getting-started-with-laravel/1608
Now that the DB is setup lets go ahead and create the corresponding model.
php artisan make:model Student
Go to app folder. You should see a new file with the class of the model you just created.
Our model can now be used to save and retrieve data.
Let us use jump into the laravel interactive mode.
php artisan tinker
A new console should appear. Start adding items
$student = new App\Student();
$student->name = "Jacob Chencha";
$student->email="jacob@chenchatech.com";
$student->course="php";
$student->save();
The student object is now saved in the database.
Exit the terminal by typing exit to the prompt
exit()
To see all students simply go to the terminal once more
App\Student::all();
See more documentation at https://laravel.com/api/5.2/Illuminate/Database/Eloquent/Builder.html
Try out all the other methods available to you via the collection interface