Hi,
I’m tryng to create a new expense listener for hard landing events, by adding a new file at /app/Listeners, but it’s not working.
I have this Laravel error:
Quote
production.ERROR: Class “App\Listeners\Expense” not found {“userId”:1,“exception”:"[object] (Error(code: 0): Class "App\Listeners\Expense" not found at /home/flyeircm/crew.flyeag.com/app/Listeners/ExpenseTouchdown.php:27)
This is the code I’m using:
\<?php namespace App\Listeners; use App\Contracts\Listener; use App\Events\Expenses; class ExpenseTouchdown extends Listener { public function handle(Expenses $event) { $expenses = []; $amount = 250; // Do your check here, return an empty array if it is ok/below your check limit (no expense needed) if (abs($event-\>pirep-\>landing\_rate) \< 500) { return $expenses; } // You can even increase the punishment here by getting a ratio // So the harder they land, the higher the punishment $amount = round($amount \* (abs($event-\>pirep-\>landing\_rate) / 500)); // Prepare a New Expense here $expenses[] = new Expense(['type'=\> ExpenseType::FLIGHT, // This must be FLIGHT for a pirep related pilot charged expense 'amount'=\> $amount, // No need to add two more digitis, 150 is 150$ or 150Eur etc. 'transaction\_group' =\> 'Hard Landing', // This is the group name, visible at financial report 'name'=\> 'Hard Landing Fee For Pirep='.$event-\>pirep-\>id, // Name is visible like a memo 'multiplier'=\> false, // or true (to use Subfleet GH Multiplier) 'charge\_to\_user'=\> true, // true to charge pilot, false to charge company]); // If you wish you can create another expense here like the one above... // And finally return all new expenses you prepared return $expenses; } }
I believe the code is right, I adapted from an example at the forum. I cleaned the cache. The filename and the inner class name declaration are matching.
Anyone can help me to find where the problem might be?
Thanks.