I have array which contains laravel model (App\User) function names like following:
$documents = array(
'passport_expire' => 22,
'residency' => 13
);
If I called these functions directly it will return a value like:
App\User::find(2)->passport_expire;//will output a boolean true / false
I want to execute the functions inside a foreach the $documents array:
foreach($documents as $type => $val){
// I want to call the function
App\User::find(1)->{$type};
//it will call and execute App\User::find(1)->passport_expire and App\User::find(1)->residency
I read in php documentation about a way with similar approach called Variable functions but I don't know how to accomplish that in laravel.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire