store 2 out of 3 fields in the database

Posted 1 month 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.