//to make a foreign key
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
//to make a table unsigned
$table->integer('user_id')->unsigned();
//to make a table nullable()
$table->string('slug')->nullable();
//to give default value in laravel
$table->tinyInteger('status')->default(1);
//what is unsigned?
The table column which is unsigned you can't insert negetive value
//to create a relation with users and tickets table Put in to User MOdel
public function tickets(){
return $this->hasMany('App\Ticket');
}
//================Tinker tutorial
//==to insert
php artisan tinker
$user = new App\User;
$user->name = 'polo';
$user->email = 'polodev10@gmail.com';
$user->password = bcrypt('1234');
$user-> save();
//==to view();
$user = App\User::first();
$user = App\User::firstOrFail();
$user = App\User::all();
$user = App\User::where('id', 1)->get();
$user = App\User::whereId(1)->get();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
//to make a table unsigned
$table->integer('user_id')->unsigned();
//to make a table nullable()
$table->string('slug')->nullable();
//to give default value in laravel
$table->tinyInteger('status')->default(1);
//what is unsigned?
The table column which is unsigned you can't insert negetive value
//to create a relation with users and tickets table Put in to User MOdel
public function tickets(){
return $this->hasMany('App\Ticket');
}
//================Tinker tutorial
//==to insert
php artisan tinker
$user = new App\User;
$user->name = 'polo';
$user->email = 'polodev10@gmail.com';
$user->password = bcrypt('1234');
$user-> save();
//==to view();
$user = App\User::first();
$user = App\User::firstOrFail();
$user = App\User::all();
$user = App\User::where('id', 1)->get();
$user = App\User::whereId(1)->get();
No comments:
Post a Comment