Skip to content
Advertisement

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, …

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 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 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

Advertisement