Avatar of B O
B O

asked on 

How do I get rid of the error: maximum execution time of 60 minutes exceeded, when loading a json file with laravel



code:
$contactInfo = Storage::disk('local')->exists('challenge.json') ? json_decode(Storage::disk('local')->get('challenge.json'), true) : [];
        
            // $json = $contactInfo[0]; // turn std object to array
            foreach ($contactInfo as $contactDetail ){
                $contact = new User; // assumes you have a Model called Contact
                $contact->name = $contactDetail['name'];
                $contact->address = $contactDetail['address'];
                $contact->checked = (!$contactDetail['checked'] === false) ? $contactDetail['checked'] : 'false';
                $contact->description = $contactDetail['description'];
                $contact->interest = (!$contactDetail['interest'] === null) ? $contactDetail['interest'] : 'null';
                $contact->date_of_birth = (!is_null($contactDetail['date_of_birth'])) 
                ? 
                substr(preg_replace("([^0-9/])", "", $contactDetail['date_of_birth']), 0, 8) 
                : 
                new DateTime('2000-01-01');
              
                $contact->email = (!$contactDetail['email'] === null) ? $contactDetail['email'] : 'null';;
                $contact->account = $contactDetail['account'];
                $contact->save();
                $sensitive_data = new Creditcard;
                $sensitive_data->type = $contactDetail['credit_card']['type'];
                $sensitive_data->number = $contactDetail['credit_card']['number'];
                $sensitive_data->name = $contactDetail['credit_card']['name'];
                $sensitive_data->expirationDate = $contactDetail['credit_card']['expirationDate'];
                $sensitive_data->save();
            }

Open in new window


Error when loading longer than a minute:




LaravelPHPJSON

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon