/** * Create Slug on prepareData, The table need to have a "slug" attribute. * The first argument is the request data to be filled on the model. * The second argument is the field on the table that will be converted to the slug. * * @param $data * @param $slug_field * @return mixed */ protected function generateSlug($data, $slug_field) { if (!$this->entity->exists() || $this->entity->{$slug_field} != $data[$slug_field]) { $data['slug'] = Sluger::generateUniqueSlug($data[$slug_field], $this->entity->getTable()); } return $data; }
/** * Prepare array to fill the conversation model. * * @return array */ public function prepareDate() { return ['user_id' => Auth::User()->id, 'title' => $this->title, 'topic_id' => $this->topic_id, 'message' => $this->converter->convertToHtml($this->message), 'slug' => Slug::generateUniqueSlug($this->title, 'conversations')]; }
/** * Prepare array to fill the conversation model. * * @return array */ public function prepareDate() { $databasePrefix = config('forum.database.prefix') ? config('forum.database.prefix') . '_' : ''; return ['user_id' => auth()->user()->id, 'title' => $this->title, 'topic_id' => $this->topic_id, 'message' => $this->message, 'slug' => Slug::generateUniqueSlug($this->title, $databasePrefix . 'conversations')]; }
/** * Prepare array to fill the conversation model. * * @return array */ public function prepareDate() { $databasePrefix = Config::get('forum.database.prefix') ? Config::get('forum.database.prefix') . '_' : ''; return ['user_id' => Auth::User()->id, 'title' => $this->title, 'topic_id' => $this->topic_id, 'message' => $this->converter->convertToHtml($this->message), 'slug' => Slug::generateUniqueSlug($this->title, $databasePrefix . 'conversations')]; }