There is a static class with a method which returns data by type:
class FactoryProfileModel {
static function get($type) {
if ($type === Type.Doctor) return DoctorModel::where("user_id", 1);
if ($type === Type.Patient) return PatientModel::where("user_id", 1);
}
}
How and where to register such a class FactoryProfileModel
to use it in the controller method where $request->type
arrives.
May be better use this as helper function?
CodePudding user response:
To use this class in a controller method, you can try this.
$profile = FactoryProfileModel::get($request->type);
You don't need to register the FactoryProfileModel
class in any specific way to use it in your controller method.
CodePudding user response:
Just create a folder inside your APP Folder and name a file like your class name. After you created it you can USE is it in your Controller by importing it with "use App\Classes\FPDF". After you can call it easy with $classInstance = new Class();