private function checkIfUnique($title) { $unique = Blog_Post::where('slug', $title)->count(); if (!$unique) { $title = $title . '-2'; $this->checkIfUnique($title); } return ''; }
Route::get('/', function () { return view('admin.index'); }); Route::get('/clients', function () { $clients = \App\Models\Client::all(); $quotes = \App\Models\Quote::all(); return view('admin.clients', ['clients' => $clients, 'quotes' => $quotes]); }); }); Route::get('/speech', function () { return view('speechdemo'); }); Route::get('/blog', function () { $posts = \App\Models\Blog_Post::with('Author')->with('picture')->get(); return view('front.blog.index', ['posts' => $posts]); }); Route::get('/blog/{slug}', function ($slug) { $post = \App\Models\Blog_Post::where('slug', $slug)->with('Author')->with('picture')->first(); if ($post) { return view('front.blog.viewPost', ['post' => $post]); } return redirect('/blog'); })->name('viewBlogPost'); Route::get('/testr', function () { return public_path('uploads/files'); }); // return dd($proj_types); // DB::enableQueryLog(); // return dd($projects[0]->getAttributes()); // return dd(DB::getQueryLog()); // return dd($projects);