Laravel Classroom image

Prashant  Nigam / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7 | 8|Last
Lessons:-The Blog Tutorial

15.2 Basic Setup
First of all you will need to setup your database and session driver, you should know how to do
this by now. I will be using mySQL as my database as always.
Now let’s create migrations for our tables, again using Artisan as we did in the migrations
chapter.
1 php artisan migrate:make create_users
Now our schema for up() along with default user account.
1 <?php
2
3 Schema::create('users', function($table) {
4 $table->increments('id');
5 $table->string('username', 128);
6 $table->string('nickname', 128);
7 $table->string('password', 64);
8 $table->timestamps();
9 });
10
11 DB::table('users')->insert(array(
12 'username' => 'admin',
13 'nickname' => 'Admin',
14 'password' => Hash::make('password')
15 ));
and let’s update our down() method just in case.1 <?php
2
3 Schema::drop('users');
Let’s also create our posts migration. I bet you didn’t see that coming?
1 php artisan migrate:make create_posts
The schema for up..
1 <?php
2
3 Schema::create('posts', function($table) {
4 $table->increments('id');
5 $table->string('title', 128);
6 $table->text('body');
7 $table->integer('author_id');
8 $table->timestamps();
9 });
and let’s tear down this table in down() too.
1 <?php
2
3 Schema::drop('posts');
Let’s run our migrations and get those tables in place.
1 php artisan migrate:install
2 php artisan migrate
Finally let’s update our authentication configuration in application/config/auth.php to use
fluent as an authentication driver, and username as a login identifier.
1 <?php
2
3 return array(
4
5 'driver' => 'fluent',
6 'username' => 'username',
7 'model' => 'User',
8 'table' => 'users',
9 );
There, now we are ready to create our Eloquent models.

 

 

 
 
 

Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)