laravel


  • (PHP) Eloquent doodles for Laravel

    [php] // Get model by primary key $myModel = MyModel::find($id); //Where can use short syntax for equal comparison. $myModels = MyModel::where(‘someAttribute’, ‘=’, ‘someValue’)->get(); $myModels = MyModel::where(‘someAttribute’, ‘someValue’)->get(); // Delete models $affectedRows = MyModel::where(‘someAttribute’, ‘someValue’)->delete(); // Select distinct $distincts = MyModel::distinct()->select(‘someAttribute’)->where(‘someAttribute’, ‘someValue’)->get(); // Select with Limit and offset $myModels = MyModel::limit(30)->get(); $myModels = MyModel::limit(30)->offset(30)->get(); [/php] Different…

  • (PHP) Using route groups in Laravel to protect routes

    To protect routes, in Laravel, from unauthorized visits you can use route groups. All routes in group will be affected by the auth before filter. [php] Route::group(array(‘before’ => ‘auth’), function() { Route::get(‘controlpanel’, ‘CustomerPanel@showPanel’); Route::get(‘secret’, ‘Secret@showSecret’); Route::post(‘setup’, ‘SetupController@doSetup’); }); [/php]

  • How to make OSX use MAMP php instead of system version

    Getting OSX to install Laravel properly is a minor nightmare. Here are some good instructions on how to get it to use MAMP php instead of the broken default one that comes with OSX. https://gist.github.com/irazasyed/5987693