store 2 out of 3 fields in the database

Posted 3 months ago by Prathamesh6921

Hii all,i am trying to solve the logic ,i want to keep 3 fields(license_institution, licences_number and file) non mandatory in the registration but now as per new requirement 2(license_institution, licences_number) of them user should be able to fill and 3rd(file) field should leave blank. how would i solve it. i am getting the call to member function on store null

if($role == 'legal'){
            $lawyer = new Lawyer();
            $lawyer->user_id = $user->id;
            $lawyer->save();
            if($request->get('licname_0') != null || $request->get('lic_no_0') != null || $request->file('lic_file_0') != null){
                for ($i = 0; $i < count($total_licenses); $i++) {
                    $filename = $request->file('lic_file_' . $i)->store('licenses');
                    $license = new License();
                    $license->lawyer_id = $lawyer->id;
                    $license->file = $filename;
                    $license->licenseno = $request->get('lic_no_' . $i);
                    $license->institution = $request->get('licname_' . $i);
                    $license->save();
                }
            }else if (($request->get('licname_0') != null || $request->get('lic_no_0') != null) && $request->file('lic_file_0') == null){
                for ($i = 0; $i < count($total_licenses); $i++) {
                    $filename = $request->file('lic_file_' . $i)->store('licenses');
                    $license = new License();
                    $license->lawyer_id = $lawyer->id;
                    $license->file = $filename;
                    $license->licenseno = $request->get('lic_no_' . $i);
                    $license->institution = $request->get('licname_' . $i);
                    $license->save();
                }
            }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.