Last active
December 9, 2016 07:43
-
-
Save syads321/8b18045007bce40196645df18fd94f0b to your computer and use it in GitHub Desktop.
Laravel command list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php artisan make:controller BookController | |
php artisan make:model --migration Post | |
//Make migration template and model named Post at same time | |
Route::get($uri, $callback); | |
Route::post($uri, $callback); | |
//Scope Model | |
class User extends Model { | |
public function scopePopular($query) | |
{ | |
return $query->where('votes', '>', 100); | |
} | |
public function scopeWomen($query) | |
{ | |
return $query->whereGender('W'); | |
} | |
} | |
$users = User::popular()->women()->orderBy('created_at')->get(); | |
One to Many | |
class User extends Model { | |
public function phone() | |
{ | |
return $this->hasOne('App\Phone'); | |
} | |
} | |
$phone = User::find(1)->phone; | |
select * from users where id = 1 | |
select * from phones where user_id = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment