public function run()
 {
     DB::table('posts')->delete();
     for ($i = 1; $i <= 100; $i++) {
         $faker = Faker::create();
         \Ciccio\Components\Posts\Post::create(['title' => $faker->name, 'body' => $faker->text]);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $post = \Ciccio\Components\Posts\Post::whereHas('categories', function ($query) use($id) {
             $query->where('slug', $id);
         })->with(['categories' => function ($query) {
             $query->select(['title', 'slug']);
         }])->orderBy('created_at', 'DESC')->paginate(5);
     } catch (\Exception $ex) {
         $post['error'] = 'Posts in this category could not be found.' . $ex->getMessage();
     }
     return $post;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $post = \Ciccio\Components\Posts\Post::findOrFail($id);
         $post->delete();
         $response = ['success', $id];
     } catch (ModelNotFoundException $ex) {
         $response = ['error' => 'Item not found'];
     }
     return response()->json($response);
 }