public function __construct() { $this->app_list_limit = env('APP_LIST_LIMIT', 50); $token = JWTAuth::getToken(); if (!empty($token)) { $user = JWTAuth::toUser($token); $this->logged_user = User::find($user->id); } }
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 getWorkDistanceAttribute() { if (Session::has('user_id')) { $user_id = Session::get('user_id'); $lat = $this->job_locations->lat; $lng = $this->job_locations->lng; $user = User::where('id', '=', $user_id)->within((int) $this->search_radius, 'kilometers', $lat, $lng)->where('lat', '!=', '')->where('lng', '!=', '')->first(); if (empty($user) || count($user) == 0) { return 0; } return $user->toArray()['distance']; } return 0; }