<?php namespace Litematrimony\Profile\Http\Controllers; use App\Http\Controllers\ActionController as BaseController; use Exception; use Litematrimony\Profile\Actions\ProfileAction; use Litematrimony\Profile\Http\Requests\ProfileActionRequest; use Litematrimony\Profile\Http\Resources\ProfileResource; use Litematrimony\Profile\Models\Profile; /** * Admin web controller class. */ class ProfileActionController extends BaseController { /** * Action controller function for profile. * * @param Model $model * @param action next action for the model. * * @return Response */ public function __invoke(ProfileActionRequest $request, Profile $profile, $action) { try { $request = $request->all(); $profile = ProfileAction::run($action, $profile, $request); $data = new ProfileResource($profile); return $this->response->message(trans("messages.success.{$action}", ['Module' => trans('profile::profile.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('profile/profile/' . $profile->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('profile/profile/' . $profile->getRouteKey())) ->redirect(); } } public function notify(){ } }