public function postUpdateAvatar() { try { $user = \User::getUser(); if (!$user->hasAccess('contractor')) { throw new \Exception("Only contractor can update their account information", 1); return; } $contractor = \Contractor::getContractor(); // TODO: change to symfony request file input $image = \Contractor::updateAvatar($contractor, $_FILES['file']); return \Response::json(['type' => 'success', 'message' => 'Avatar has been updated.', 'image' => asset($image->image)]); } catch (\Exception $e) { return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]); } }