public function run()
 {
     $uncategorized = DB::table('categories')->where('slug', 'uncategorized')->get();
     if (count(DB::table('categories')->get()) == 0 && empty($uncategorized)) {
         Category::create(['title' => 'Uncategorized', 'description' => 'Default category', 'slug' => 'uncategorized']);
     }
 }
 /**
  * Remove the specified category from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     return redirect()->route('admin.categories.index');
 }
예제 #3
0
 /**
  * Show the form for editing the specified post.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $post = Post::find($id);
     $viewData = ['pageTitle' => 'Edit Post: ' . $post->title, 'post' => $post, 'categories' => Category::lists('title', 'id')];
     return view('posts.edit', $viewData);
 }