depends on what the meaning of "alert message"
most browser is not allowed use javascript alert
and are you looking for return old('variable') if Validation fail ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys I am working with a project milkfarm. My problem is I need an alert box instead of success flash message in controller. How it is possible? My client is asking to give an alert box instead of success message because when I enter the whole data in the form and click insert it moves to controller store() function and adds the data in the DB. But sometimes I need to check few values in the controller (say for example balance_amount<given_amount, total_stock<sold_stock) after that only i can insert those values
If these problem occurs it should throw an alert message to user to enter the correct amount or stock. My client doesn’t need flash messages for these checking. For successful insert flash message is ok but for cheking alert messages is needed. Both are done in same function store().
So kindly anyone help to make my problem solve . suggest some ideas please
Guys this worked
controller
return redirect()->back() ->with('alert', 'Updated!');
<script>
var msg = '{{Session::get('alert')}}';
var exist = '{{Session::has('alert')}}';
if(exist){
alert(msg);
}
</script>
Please or to participate in this conversation.