mercredi 21 novembre 2018

Php Larvel include model in middle of the program

I want to add models from one table called "modellist" in middle of the program.

foreach ($trans_infos as $key => $trans_info) {
                if($trans_info->heirarchy_type==1 || $trans_info->heirarchy_type==2){
                    $model=TransactionModules::where('id',$info->module_id)->first();
                    $model_name=$model->model; // here am getting model name form table
                    use  App\Models\.$model_name; //i used this function to include model on middle of program  
                    $model_name::find($info->transaction_id)->update(['status' => 7]);
                }
            }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire