laravel include a class in controller file code example
Example 1: how to put external file in laravel listener class
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/functions/prices.php"
]
},
Example 2: how to put external file in laravel listener class
namespace App\Http\Controllers;
use App\Classes\PricesClass;
class PagesController extends Controller
{
public function getHome()
{
$pricesClass = new PricesClass();
$prices = $pricesClass->getPrices();
return view('pages.home', compact('prices'));
}
}