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());
Tag: laravel
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
How do I get the query builder to output its raw SQL query as a string?
Given the following code: I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be SELECT * FROM users. How do I do this? Answer To output to the screen the last queries ran you can use this: I believe the most recent queries will be at the
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
What’s the best way to validate numbers with comma as decimal separator?
In a Laravel app, I have a form on which I need to validate numbers with a comma as the decimal separator. For the moment, it only works with a point because my validation rule is: What’s the best method : Keep the rule and replace comma with point before validation ? Is there a before_validation observer or something like
Laravel: belongsTo() relation assume one-to-many relationship instead of one-to-one
I’m having a tedious problem with Laravel’s ORM. I have a model with multiple relationships, like this: Now I can access the template related item in a simple way, like this: And it works out of the bat, because Laravel’s ORM assumes it is a one-to-one relationship and internally calls the first() method. But when I try the same with
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
how to make a varchar nullable and unique together in mysql (laravel)
Can i make a MySQL column nullable and unique together. I have a table that store users Email_id if user wants to provide else it will be (null). I read in some other questions that i can make a unique field with default NULL. but i get this error when creating table the main table is generated with larave schema