Repository for the laracasts lessons
Installing Laravel, teaching the basics of MVC architecture, scaffolding, databases, and configurations. Good place to start, but it doesn't go much beyond the Laravel documentation.
Creating the database and connecting it to the Laravel Application.
Files changed:
app/config/database.php
app/routes.php
Code Added:
//get all users from the table
Route::get('/', function() {
$users = DB::table('users')->get();
dd($users);
});
// get the first user of a table
Route::get('/', function() {
$user = DB::table('users')->find(1);
dd($user);
});
</code></pre>
Eloquent Basics
Explanation of Laravel's ORM, called eloquent. Makes writing database queries a cinch.
Files changed:
app/routes.php
Code Added:
// // Laravel ORM
// Route::get('/', function() {
// // below statement is the same as $users = DB::table('users')->where('username', '!=', 'max')->get();
// $users = User::where('username', '!=', 'max')->get();
// return $users;
// });
// // grab all users
// Route::get('/', function() {
// $users = User::all();
// return $users;
// });
// // create a user
// Route::get('/', function() {
// // // long way of doing it
// // $user = new User;
// // $user->username = 'NewUser';
// // $user->password = Hash::make('password');
// // $user->save();
// // Short way of doing it by creating an object
// User::create([
// 'username' => 'AnotherUser',
// 'password' => Hash::make('anotherpassword')
// ]);
// return User::all();
// });
// Update a user
Route::get('/', function() {
$user = User::find(2);
$user->username = 'UpdatedName';
$user->save();
return $user;
});
Blade Basics
Laravel's templating engine. This lesson creates a simple layout for displaying users.
Files changed:
Code Added: