@snapey thanks for the feedback, felt like overkill extending a model for this. Traits felt just right, but I couldn't get it right.
Here's what I tried:
namespace App\Traits;
trait Detailable
{
public function getAttribute($key)
{
if ($key == 'details') return $this->details;
}
public function setAttribute($key, $value)
{
// don't really care about the setAttribute...
return parent::setAttribute($key, $value);
}
}
Basically if the key is 'details', return the protected member variable. It would always return null for me. Any ideas?
@snapey Thanks, I think that's the best answer right now, I was just hoping to avoid copy/paste the same accessor in multiple models. Would be nice if this could be done through a trait somehow.
@snapey thanks again for the help! I thought I tried adding that to a trait before and had issues, but I guess not. I did what you suggested and that worked perfectly. Thanks!