public function authorize() { if ($this->entity()) { if ($this->user()->can('view', $this->entity())) { HistoryUtils::trackViewed($this->entity()); return true; } } else { return $this->user()->can('create', $this->entityType); } }