Upgraded to L5 and loving it! However currently facing an issue with polymorphing a relationship. In my userable column in the Users table I need to include the namespaced value (e.g. "App\Employee" rather than just "Employee") for the polymorph relationship to work.
Feels like I am missing something.. How do I avoid forcing to store namespaced values in the table? :)
PS: Well aware others are struggling with similar issues (e.g. Laravel 5 namespaces) but have not seen anything relating to avoiding to store the namespacing in the tables..
BaseController
<?php namespace App\Http\Controllers;
use App\Client;
use App\User;
...
HomeController
$user = User::with('userable')->get();
foreach ($user as $u){
var_dump($u->userable->mobile);
}
User model
public function userable()
{
return $this->morphTo();
}
Client model
public function user()
{
return $this->morphOne('App\User', 'userable');
}
Employee model
public function user()
{
return $this->morphOne('App\User', 'userable');
}