Ejemplo n.º 1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('bin', function ($value) {
         $id = hashid()->decode($value);
         if (empty($id)) {
             $id = null;
         } else {
             $id = $id[0];
         }
         return Bin::where('id', $id)->first();
     });
     $router->bind('comment', function ($value) {
         $id = hashid()->decode($value);
         if (empty($id)) {
             $id = null;
         } else {
             $id = $id[0];
         }
         return Comment::where('id', $id)->first();
     });
     parent::boot($router);
 }
Ejemplo n.º 2
0
 public function deletePost(Bin $bin, Comment $comment)
 {
     $comment->delete();
     session()->flash('success', 'Comment deleted successfully!');
     return redirect()->route('bin.code', $bin->getRouteKey());
 }