So, i'm running Laravel 5.3 and i'm trying to run a config class method that sets up a map using a setMap method. This method takes keys and values (names of fields in my DB) and will parse them into an associative array with those same keys but values from my DB.
So for instance
$this->getParser()->setMap([
'id' => 'id',
'name' => function(Record $lead) {
return $lead->firstName . ' ' . $lead->lastName;
},
]);
In that example 'id' is assumed to be a field in the DB and in Closure i want to get two specific values from my Record model once for each record in a query.
The structure of the app is
Route : /show/id/21
Instantiates : new 'Config_{$id}' (after checking the class exists ofc)
Runs the Setup Method : $config->setup()
This runs the setup method, there's an abstract base class of all configs, where i do most of my logic, such as getting records from the database, sending them via CSV.
But how can i redesign this so that i can access the Model or inject it into the setup method and be able to set up a map for each record.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire