モデル
class Profile extends Eloquent {
public function user(){ return $this->belongsTo('User'); }
public function url(){
return URL::Route('profile', array('city_slug' => $this->city_slug, 'slug'=> $this->slug));
}
}
コントローラ
class ProfileController extends BaseController {
public function show($user_id)
{
$profile = Profile::with('user')->where('user_id', $user_id);
return Response::json($profile, 200);
}
}
Profile メソッド url(){} から生成された URL をレスポンスに含めたいです。
{
"id" : 1,
"url" : /profile/{city_slug}/{slug},
....
}
前もって感謝します。