John Davidson

php - Route [report.expAlert] not defined

0 comments
Message:


Route report.expAlert error
(View: /home/grocersa/edesimarket.com/resources/views/layout/main.blade.php
(i defined all place but not triggered plz help to find out)


This is my web.php file coding


Route::get('report/product_quantity_alert', 'ReportController@productQuantityAlert')->name('report.qtyAlert');
Route::get('report/product_expiry_alert', 'ReportController@productExpiryAlert')->name('report.expAlert');
Route::get('report/warehouse_stock', 'ReportController@warehouseStock')->name('report.warehouseStock');

This my main.blade.php coding


for sidebar (nav - menu )


  @if($product_exp_alert_active)
<li id="expAlert-report-menu">
<a href="{{route('report.expAlert')}}">{{trans('file.Product Expiry Alert')}}</a>
</li>
@endif

for user permission


@if($product_qty_alert_active || $product_exp_alert_active)

for database & roll permission


 $product_qty_alert_active = DB::table('permissions')
->join('role_has_permissions', 'permissions.id', '=', 'role_has_permissions.permission_id')
->where([
['permissions.name', 'product-qty-alert'],
['role_id', $role->id] ])->first();
$product_exp_alert_active = DB::table('permissions')
->join('role_has_permissions', 'permissions.id', '=', 'role_has_permissions.permission_id')
->where([
['permissions.name', 'product-exp-alert'],
['role_id', $role->id] ])->first();

for define


 @if($alert_product > 0)
<li class="nav-item">
<a rel="nofollow" data-target="#" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-item"><i class="dripicons-bell"></i><span class="badge badge-danger">{{$alert_product}}</span>
</a>
<ul class="dropdown-menu edit-options dropdown-menu-right dropdown-default notifications" user="menu">
<li class="notifications">
<a href="{{route('report.qtyAlert')}}" class="btn btn-link"> {{$alert_product}} product exceeds alert quantity</a>
</li>
<li class="notifications">
<a href="{{route('report.expAlert')}}" class="btn btn-link"> {{$alert_product}} product expiry alert</a>
</li>
</ul>
</li>
@endif

This is my reportcontroller.php coding


class ReportController extends Controller
{
public function productQuantityAlert()
{
$role = Role::find(Auth::user()->role_id);
if($role->hasPermissionTo('product-qty-alert')){
$lims_product_data = Product::select('name','code', 'image', 'qty', 'alert_quantity')->where('is_active', true)->whereColumn('alert_quantity', '>', 'qty')->get();
return view('report.qty_alert_report', compact('lims_product_data'));
}
else
return redirect()->back()->with('not_permitted', 'Sorry! You are not allowed to access this module');
}

public function productExpiryAlert()
{
$role = Role::find(Auth::user()->role_id);
if($role->hasPermissionTo('product-exp-alert')){
$lims_product_data = Product::select('name','code', 'image', 'qty', 'alert_expiry')->where('is_active', true)->whereColumn('alert_expiry', '>', 'name')->get();
return view('report.exp_alert_report', compact('lims_product_data'));
}
else
return redirect()->back()->with('not_permitted', 'Sorry! You are not allowed to access this module');
}


My Answer:
It looks like you are trying to access the route `report.expAlert` but it is not defined in your `web.php` file.

To fix this issue, you need to define the route in your `web.php` file like this:

php
Route::get('report/expAlert', 'ReportController@expAlert');


Make sure that the method `expAlert` exists in your `ReportController` and that it is spelled correctly.

After defining the route, you should be able to access it in your view file `/home/grocersa/edesimarket.com/resources/views/layout/main.blade.php` using the route helper function like this:

php
{{ route('report.expAlert') }}


This should resolve the issue and allow you to access the `expAlert` route in your application.

Rate this post

5 of 5 based on 8169 votes

Comments




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