芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/tblonline.org/app/Models/News.php
attributes['slug'] = $this->generateSlug($value); } public function author() { return $this->belongsTo('App\Models\User', 'user_id')->withDefault(); } private function generateSlug($value) { $slug = mb_strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $value))); $count = News::where('slug', 'LIKE', $slug . '%')->count(); $suffix = $count > 0 ? $count + 1 : ""; $slug .= $suffix; return $slug; } }