Laravel Montréal #7 - March 12th, 2015
Thanks for comming !
Sponsors
Jobs
Get involved
composer create-project laravel/laravel unicorn --prefer-dist
php artisan app:name Unicorn
namespace App\Handlers\Commands;
use Illuminate\Contracts\Mail\Mailer;
class PurchasePodcastHandler {
protected $mailer;
public function __construct()
{
$this->mailer = new Mailer;
}
}
namespace App\Handlers\Commands;
use Illuminate\Contracts\Mail\Mailer;
class PurchasePodcastHandler {
protected $mailer;
public function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
}
}
namespace App\Handlers\Commands;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\OtherClass;
use Illuminate\Contracts\Validator;
use Illuminate\Contracts\SomethingElse;
class PurchasePodcastHandler {
[...]
public function __construct(Mailer $mailer, OtherClass $otherClass, Validator $validator, SomethingElse $somethingElse)
{
$this->mailer = $mailer;
$this->otherClass = $otherClass;
$this->validator = $validator;
$this->somethingElse = $somethingElse;
}
}
namespace App\Handlers\Commands;
use Illuminate\Contracts\Mail\Mailer;
class PurchasePodcastHandler {
protected $mailer;
public function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
}
public function handle(Validator $validator) {
$validator->run();
}
}
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Response;
class FriendFormRequest extends FormRequest
{
public function rules()
{
return [
'first_name' => 'required',
'email_address' => 'required|email'
];
}
php namespace App\Http\Controllers;
use App\Http\Requests\FriendFormRequest;
use Illuminate\Routing\Controller;
use Response;
class FriendsController extends Controller
{
public function getAddFriend()
{
return view('friends.add');
}
public function postAddFriend(FriendFormRequest $request)
{
$this->command('addFriend', \Request::input());
return Response::make('Friend added!');
}
}
$schedule->command('cache:clear')
->hourly()
->sendOutputTo($filePath)
->emailOutputTo('john@doe.com');
$schedule->command('foo')->dailyAt('15:00');
$schedule->command('foo')->thenPing($url);
$schedule->command('foo')->cron('* * * * *');
$schedule->call(function()
{
// Do some task...
})->hourly();
$contents = Storage::get('file.jpg');
Storage::put('file.jpg', $contents);
Storage::delete('file.jpg');
Storage::move('old/file1.jpg', 'new/file1.jpg');
Storage::copy('old/file1.jpg', 'new/file1.jpg');
$file = Storage::disk('s3')->get('file.jpg');
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'is_admin' => 'boolean',
'friends' => 'array',
'somethingHere' => 'integer',
'somethingElse' => 'float',
];