Sunday, March 12, 2017

Laravel: Script message is not showing

i want to delete a row from my database after clicking a href link. It is working fine. But after completing deletion i want show a message to the user. but it is not showing. my code is here:

public function postDelete($booked_by)
        {
            $user_id = Auth::user()->id;
            $booking_id = DB::table('bookings')
                        ->select('id')
                        ->where('booked_by', '=', $user_id)
                        ->get();

           // dd($booking_id);

            if($user_id == $booking_id)   
            {
            $user = DB::table('bookings')
                  ->where('booked_by', '=', $user_id)
                  ->delete();  

            return back();
            $message = "Your booking is canceled";
            echo "<script type='text/javascript'>alert('$message');       </script>";

            else   
            {
                 $message = "You can't delete which is booked by others";
                echo "<script type='text/javascript'>alert('$message');</script>";}


                  return back();


        }   

what should i change?



via incorporeal

Advertisement