'calendar.browse', 'create' => 'calendar.create', 'update' => 'calendar.update', 'destroy' => 'calendar.destroy', ]; // permissions... protected $moduleSettingsLinks = [ ]; protected $settingsPermission = 'calendar.settings'; protected $showFields = [ 'information' => [ 'name' => [ 'type' => 'text', 'col-class' => 'col-lg-10' ], 'is_public' => [ 'type' => 'checkbox', 'col-class' => 'col-lg-2' ], 'first_day' => [ 'type' => 'checkbox', 'col-class' => 'col-lg-4' ], 'default_view' => [ 'type' => 'text', 'col-class' => 'col-lg-4' ], 'day_start_at' => [ 'type' => 'text', 'col-class' => 'col-lg-4' ], ], ]; protected $routes = [ 'index' => 'calendar.calendars.index', 'create' => 'calendar.calendars.create', 'show' => 'calendar.calendars.show', 'edit' => 'calendar.calendars.edit', 'store' => 'calendar.calendars.store', 'destroy' => 'calendar.calendars.destroy', 'update' => 'calendar.calendars.update' ]; protected $languageFile = 'calendar::calendar'; public function __construct() { parent::__construct(); } public function edit($identifier) { $user = \Auth::user(); $repository = $this->getRepository(); $entity = $repository->find($identifier); if (!$user->access_to_all_entity) { if ($entity->is_public) { //Overrite to allow edit public calendar only by creator if ($entity->created_by != \Auth::user()->id) { flash(trans('calendar::calendar.allowed_only_by_creator'))->error(); return redirect(route('calendar.index')); } } } return parent::edit($identifier); } /** * Update entity * * @param $identifier * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($identifier) { if ($this->permissions['update'] != '' && !\Auth::user()->hasPermissionTo($this->permissions['update'])) { flash(trans('core::core.you_dont_have_access'))->error(); return redirect()->route($this->routes['index']); } $repository = $this->getRepository(); $entity = $repository->find($identifier); $this->entity = $entity; if (empty($entity)) { flash(trans('core::core.entity.entity_not_found'))->error(); return redirect(route($this->routes['index'])); } if ($this->blockEntityOwnableAccess()) { flash(trans('core::core.you_dont_have_access'))->error(); return redirect()->route($this->routes['index']); } $input = $this->form($this->formClass)->getFieldValues(true); $repository = $this->getRepository(); $entity = $repository->updateEntity($input, $entity); $this->afterUpdate(request(), $entity); $this->updateNotification($entity); $this->entity = $entity; flash(trans('core::core.entity.updated'))->success(); return redirect(route($this->routes['show'], $entity)); } public function index(Request $request) { return redirect()->route('calendar.index'); } }