Laravel Eloquent setting a default value for a model relation?
I have two models: class Product extends Eloquent { ... public function defaultPhoto() { return $this->belongsTo('Photo'); } public function photos() { return $this->hasMany('Photo'); } } class Photo extends Eloquent { ... public function getThumbAttribute() { return 'products/' . $this->uri . '/thumb.jpg'; } public function getFullAttribute() { return 'products/' . $this->uri . '/full.jpg'; } ... } 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