Focused on my improvement as a developer, the Project Flyer follows many of the techniques tought by Jeffrey Way on his site Laracasts.
Important note! Site has being updated to GitHub to show how I'm working under a developement environment, not a production one.
Developed with Laravel 5.2.
Also used:
- Bootstrap 3
- jQuery
Currently working on this project, so stay tunned for more updates.
Some of good practices and techniques applied are:
public function scopeLocatedAt($query,$zip, $street)
{
return $query->where(compact('zip','street'))->firstOrFail();
}
public function getPriceAttribute($price)
{
return number_format($price,2,',','.') . '€';
}
action="{{ route('store_photo_path',['zip' => $flyer->zip, 'street' => $flyer->street]) }}"
Laravel's Gates allows to create ACL:
$gate->define('upload-images', function($user, $flyer){
return $user->id == $flyer->user_id;
});
ACL also used on Blade:
@can('upload-images',$flyer)
// ...
@endcan
Middlewares are used for authorization:
public function __construct()
{
$this->middleware('auth',['except' => 'show']);
}
Simply routing on a RESTful way but also taking care about SEO good practices
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/', 'PagesController@home');
Route::resource('flyers','FlyersController');
Route::get('{zip}/{street}','FlyersController@show');
Route::post('{zip}/{street}/photos',['as' => 'store_photo_path','uses' => 'PhotosController@store']);
});
Code styled following many of the PSR2 recommendations. Stil pending some comments about the ins and outs for each method.
You can find more info about me at Linkedin.
My reputation level in Stack Overflow is 68, with 12 badges won, check [my Stack Overflow profile] (http://stackoverflow.com/users/2172942/joss).