Skip to content
Advertisement

Tag: laravel

Is it possible to store an array as flash data in Laravel?

I have been looking around for a way of doing this. I know it is possible to store an array in the session with the following: Session::push(‘user.teams’, ‘developers’); Is it possible to do the same but with flash data? Something like Session::flashpush(‘user.teams’, array(‘developers’, ‘designers’)); would be great. The usecase for me at this moment is primarily the following: Session::flash(‘flash_message’, $validator->messages());

Laravel templates/controllers not updating on save

I’m running a Laravel 4 for a simple app on OS X. Basically, changes to controllers and templates don’t take effect for a long time after I save changes to those files. For example, I add a word to /app/views/index.blade.php, and don’t see any change when constantly refreshing my browser for another minute or so. This makes iterative development understandably

Escape raw SQL queries in Laravel 4

How does one go about escaping parameters passed to a raw query in Laravel 4? I expected something like DB::escape() (which rings a bell from Laravel 3) and also attempted DB::quote() (which I thought could be available through the PDO object) We can’t use the select method with placeholders as the above is just a simplified example of what we

Laravel or where

Currently I am working on a project in Laravel but I am stuck.I want to create a SQL statement like this: Now I have this code: But that generates: How can I get the correct “or” order? Answer Check out the Logical Grouping section in the docs: https://laravel.com/docs/master/queries#logical-grouping It explains how to group conditions in the WHERE clause. It should

Calling other function in the same controller?

I’ve this controller, and the function read($q) return error Call to undefined function sendRequest() I’m assuming it’s because I’m referencing the function in the wrong manner, but I can’t find any explanations for how to do it. Answer Try: Since PHP is not a pure object-oriented language, it interprets sendRequest() as an attempt to invoke a globally defined function (just

Get previous attribute value in Eloquent model event

Is there a way to see the old/previous value of a model’s attribute in its saving or updating event? eg. Is something like the following possible: Answer 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: Be careful, prior

Advertisement