If I am creating a Facade, and I want to pass parameters before it becomes instantiated, what do I do?
Tag: laravel-4
Return multiple array to Response::json laravel?
How we can return multiple array in json. Suppose we get the following response in Laravel eloquent: Now I want to return response in json which include these data: Using the above method empty value is returned. Any help would be appreciated Sorry guys. I found the solution. The data that I was passing was a…
Laravel 4 – Redirect back to the same page where the request comes from
In Laravel 4, I want to redirect the user back to the page from where the request came. For example, a user tries to update his profile so edits the profile and hits SAVE. In controller I do the update and normally I would do Redirect::to(‘profile’)->with(‘message’,’Profile sa…
Laravel pagination pretty URL
Is there a way to get a pagination pretty URL in Laravel 4? For example, by default: http://example.com/something/?page=3 And what I would like to get: http://example.com/something/page/3 Also, …
Laravel 4 – two submit buttons in one form and have both submits to be handled by different actions
I have a login form which has email and password fields. And I have two submit buttons, one for login ( if user is already registered ) and the other one for registration ( for new users ). As the login action and register action are different so I need some way to redirect the request with all the post
Laravel Eloquent setting a default value for a model relation?
I have two models: This works fine, I can call $product->defaultPhoto->thumb and $product->defaultPhoto->full and get the path to the related image, and get all photos using $product->photos and looping through the values. The problem arises when the product does not have a photo, I can’t…
Laravel – Check if @yield empty or not
Is it possible to check into a blade view if @yield have content or not? I am trying to assign the page titles in the views: @section(“title”, “hi world”) So I would like to check in the main …
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…
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 abov…
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 …