how to call a php file in controller in laravel 8 code example

Example 1: how to put external file in laravel listener class

namespace App\Http\Controllers;

use App\Classes\PricesClass;

class PagesController extends Controller
{
  /**
   * Display homepage.
   *
   * @return Response
   */
  public function getHome()
  {
    $pricesClass = new PricesClass();
    $prices = $pricesClass->getPrices();
    return view('pages.home', compact('prices'));
  }

}

Example 2: how to put external file in laravel listener class

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/functions/prices.php"
        ]
    },

Tags:

Php Example