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 saved!’). But what I want is to simply redirect it back with message. May
Tag: laravel
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: Get Object From Collection By Attribute
In Laravel, if I perform a query: $foods = Food::where(…)->get(); …then $foods is an Illuminate Collection of Food model objects. (Essentially an array of models.) However, the keys of this …
How to display a readable array – Laravel
After I write: And after I refresh the browser I get an unreadable array. Is there a way to get that array in a readable format? Answer dd() dumps the variable and ends the execution of the script (1), so surrounding it with <pre> tags will leave it broken. Just use good ol’ var_dump() (or print_r() if you know it’s
Laravel Eloquent inner join with multiple conditions
I have a question about inner joins with multiple on values. I did build my code like this in laravel. public function scopeShops($query) { return $query->join(‘kg_shops’, function($join) {…
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 seem to figure out a way to set a default value for such a scenario.
Laravel default orderBy
Is there a clean way to enable certain models to be ordered by a property by default? It could work by extending the laravel’s QueryBuilder, but to do so, you’ll have to rewire some of it’s core features – bad practice. reason The main point of doing this is – one of my models get’s heavily reused by many others
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 4 where in condition with DB::select query
I have next SQL query: How should I execute this using Laravel? I put this query in DB::select function, but how can I place all ids in “WHERE device_id IN (?)” condition? I tried using “array(implode(‘,’, $var))” but it doesnt work. If I have ids like “13, 14” I get results only for id = 13. So the question is