incorporeal incorporeal - 1 year ago 72
PHP Question

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 if condition is also not is showing

Object of class Illuminate\Support\Collection could not be converted to int

my code is here:

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

// dd($booking_id);

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

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

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

return back();


what should i change?

Answer Source

Please use Flash Message in this case:

If you use alert message it's really dangerous with XSS bugs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download