public function getReceiverAttribute() { $user_id = $this->receiver_id; $company = Company::with('company_logo_detail')->where('user_id', '=', $user_id)->first(); $data = []; $type = 'user'; if (!empty($company)) { $data = $company; $type = 'employer'; } else { $data = User::with('profile_image_detail')->where('id', '=', $user_id)->first(); } return ['type' => $type, 'data' => $data]; }
public function getAllUsers() { try { $company_ids = Company::lists('user_id'); return User::with('profile_image_detail', 'profile_cover_detail')->whereNotIn('id', $company_ids)->get()->toArray(); } catch (Exception $e) { return Response::json(['error' => $e->getMessage()]); } }