/** * Display a listing of the resource. * * @return Response */ public function index() { if (Input::has('params') && Input::get('params') == 'favorites') { $objs = FavoriteProject::where('user_id', Auth::user()->id)->get(); return $objs; } return Project::where('user_id', Auth::user()->id)->get(); }
public function getIsFavoriteAttribute() { $obj = FavoriteProject::where('project_id', $this->id)->where('user_id', Auth::user()->id)->first(); if ($obj) { return true; } return false; }