Skip to content
Advertisement

Tag: laravel

PHP Laravel – Allow users to use a custom domain name

I’ve looked through pretty much every single page I could find on the topic, but I’m still bit confused. I have a PHP Laravel 4.0 web site, which is at http://www.mywebsite.com When a user signs up, each user gets their own page http://user1.mywebsite.com I have set the above via wildcard sub domain on my VPS DNS manager (Linode). And in

laravel foreach loop in controller

i have a problem about looping data in controller (laravel 4). my code is like this: when i want to use foreach to loop for $product result with code like this: the result is returning error Undefined property: IlluminateDatabaseEloquentCollection::$sku so, i try to improvise a little with this code: the code returning error like this: Invalid argument supplied for foreach()

Laravel Eloquent – Attach vs Sync

What is the difference between attach() and sync() in Laravel 4’s Eloquent ORM? I’ve tried to look around but couldn’t find anything! Answer attach(): Insert related models when working with many-to-many relations No array parameter is expected Example: sync(): Similar to the attach() method, the sync() method is used to attach related models. However, the main differences are: sync() accepts

Laravel Check If Related Model Exists

I have an Eloquent model which has a related model: When I create the model, it does not necessarily have a related model. When I update it, I might add an option, or not. So I need to check if the related model exists, to either update it, or create it, respectively: Where <related_model_exists> is the code I am looking

Laravel: Validation unique on update

I know this question has been asked many times before but no one explains how to get the id when you’re validating in the model. My validation rule is in the model so how do I pass the ID of the record to the validation rule. Here is my models/User models/BaseModel Answer One simple solution. In your Model In your

Advertisement