Composer: required packages with differing levels of minimum-stability

The answer is just add @dev { “require”: { “cartalyst/sentry”: “2.0.*@dev” }, } You can read more about minimum stability settings here. An alternative is to set your minimum-stability to dev, but tell composer you want to use stable whenever possible: “minimum-stability”: “dev”, “prefer-stable” : true This basically means it will always use stable UNLESS … Read more

How to manually create a new empty Eloquent Collection in Laravel 4

It’s not really Eloquent, to add an Eloquent model to your collection you have some options: In Laravel 5 you can benefit from a helper $c = collect(new Post); or $c = collect(); $c->add(new Post); OLD Laravel 4 ANSWER $c = new \Illuminate\Database\Eloquent\Collection; And then you can $c->add(new Post); Or you could use make: $c … Read more

What is the difference between queue:work –daemon and queue:listen

Edit updated 2017-04-07: There are now three ways to run your queue: queue:work – this is the new “daemon” process (the flag is no longer required). The framework will fire up “once” – and then keep looping through the jobs. This will continue indefinitely. It uses less memory/cpu than queue:listen because the framework stays up … Read more

global variable for all controller and views

Okay, I’m going to completely ignore the ridiculous amount of over engineering and assumptions that the other answers are rife with, and go with the simple option. If you’re okay for there to be a single database call during each request, then the method is simple, alarmingly so: class BaseController extends \Controller { protected $site_settings; … Read more

Laravel Mail::send() sending to multiple to or bcc addresses

I’ve tested it using the following code: $emails = [‘myoneemail@esomething.com’, ‘myother@esomething.com’,’myother2@esomething.com’]; Mail::send(’emails.welcome’, [], function($message) use ($emails) { $message->to($emails)->subject(‘This is test e-mail’); }); var_dump( Mail:: failures()); exit; Result – empty array for failures. But of course you need to configure your app/config/mail.php properly. So first make sure you can send e-mail just to one user and … Read more

Get previous attribute value in Eloquent model event

Ok, I found this quite by chance, as it’s not in the documentation at present… There is a getOriginal() method available which returns an array of the original attribute values: User::updating(function($user) { if ($user->username != $user->getOriginal(‘username’)) { doSomething(); } // If you need multiple attributes you may use: // $originalAttributes = $user->getOriginal(); // $originalUsername = … Read more

Laravel rule validation for numbers

If I correctly got what you want: $rules = [‘Fno’ => ‘digits_between:2,5’, ‘Lno’ => ‘numeric|min:2’]; or $rules = [‘Fno’ => ‘numeric|min:2|max:5’, ‘Lno’ => ‘numeric|min:2’]; For all the available rules: http://laravel.com/docs/4.2/validation#available-validation-rules digits_between :min,max The field under validation must have a length between the given min and max. numeric The field under validation must have a numeric … Read more