本文整理汇总了PHP中Laravel\Str::slug方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::slug方法的具体用法?PHP Str::slug怎么用?PHP Str::slug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Str
的用法示例。
在下文中一共展示了Str::slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($id)
{
if (!$this->find($id)) {
return $this;
}
$this->model = $this->model->first();
if ($this->versioned && !$this->multilanguage) {
$latest_version = DB::table($this->table)->where_id($this->model->get_key())->max('version');
$this->model->version = is_null($latest_version) ? 0 : $latest_version + 1;
$this->model->exists = false;
}
if ($this->multilanguage) {
if ($this->parent) {
$this->input[$this->parent->language_table_foreign_key] = $this->parent->model->id;
return $this->create();
}
$lang_input = array();
foreach ($this->input['lang'] as $id => $input) {
$input['language_id'] = $id;
$input[$this->language_table_foreign_key] = $this->id;
$lang_input[] = $input;
}
unset($this->input['lang']);
$dal = DAL::model($this->language_model)->parent($this)->versioned($this->versioned)->input($lang_input)->update_multiple();
if (!$dal->code == 200) {
$this->data = $dal->data;
$this->code = $dal->code;
return $this;
}
} elseif (!is_null($this->slug) || isset($this->parent) && !is_null($this->parent)) {
$key = isset($this->parent) && !is_null($this->parent) ? $this->parent->slug : $this->slug;
$this->input['slug'] = Str::slug($this->input[$key]);
}
// Fill the model
$this->model->fill($this->input);
// Try to save
if ($this->model->save() === false) {
$this->code = 400;
$this->data = (array) $this->model->errors->messages;
}
$this->sync();
return $this;
}