John Davidson

php - Only some functions controller work with laravel messages


I have this functions in my controller

All functions here is working, but the "message" part is not working

I want to show a notification (like in the screenshot below) to be displayed after the functions are executed

public function destroy($id)
return response()->json(["message" => __('digestReport.delete.success')]);

public function sendTest($id){
return redirect()->route('', $id)
->with(["message" => __('digestReport.send.test')]);

public function startStop($id){


return redirect()->route('digest-report.index')
->with(["message" => __('digestReport.startStop.stopped')]);
} else {
return redirect()->route('digest-report.index')
->with(["message" => __('digestReport.startStop.started')]);

none of the 3 generates response messages, however all work fine, create and edit work fine, with their respective messages

my api.php

Route::get('/digest-report/send-test/{digest_report}', 'DigestReportController@sendTest')->name('digest-report.send-test');
Route::get('/digest-report/start-stop/{digest_report}', 'DigestReportController@startStop')->name('digest-report.start-stop');

my web.php

 Route::resource('digest-report', 'DigestReportController', ['middleware' => ['role:superadministrator|administrator|user']]);

example with store function, it works, I want to do this, this is for my store function in the same controller

public function store(MeoRequest $request)
$userId = Auth::id();
$this->meoRepository->saveDigestReport($request, $userId);
return redirect()->route('digest-report.index')
->with(["message" => __('')]);

and it works correctly

this is my index view, in the part of message notification content

<div class="row">
<div class="col-lg-12">
class="alert alert-{!! Session::has('status') ? Session::get('status') : 'info' !!} alert-dismissable">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
{!! Session::get('message') !!}

My Answer:
laravel messages are not displaying properly. Can you please provide more information on what specific issue you are facing with the laravel messages?

Rate this post

3 of 5 based on 9040 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us