Example (A as I understand you):
Assuming you have a Controller:
namespace App\Http\Controllers;
class PagesController extends Controller
{
public function getHome()
{
return view('pages.home');
}
}
And you want to use the following class:
class PricesClass {
public function getPrices() {
return ['bronze' => 50, 'silver' => 100, 'gold' => 150];
}
}
You can put a class itself anywhere you like within the \ App
folder
Saying this, in this example, you can save the class as APP \ Classes \ PricesClass.php . Then you add the namespace App \ Classes .
Then the use of the class would be like this:
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'));
}
}
Another option
For example you have this archivo.php which is not a class or anything, just a function:
<?php
function getPrices() {
return ['bronze' => 50, 'silver' => 100, 'gold' => 150];
}
You can use PHP functions such as include () or require () without forgetting the app_path () function.
Staying as follows:
public function getHome()
{
include(app_path() . '\functions\archivo.php');
$prices = getPrices();
// ...
You can check the original source for a better understanding.