/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->command('inspire')->hourly(); $schedule->call(function () { $name = substr(md5(time()), 10); $price = random_int(5, 200); $data = ['name' => $name, 'price' => $price, 'product_identifier' => substr(md5($name . $price . md5(time())), 0, 7)]; $product = Product::firstOrCreate($data); })->everyMinute(); }
function addProductDescription($user, $productCodeArray, $productDescriptionData) { $product = Product::firstOrCreate($productCodeArray); $productDescription = new ProductDescription($productDescriptionData); $productDescription->product()->associate($product); $user->product_descriptions()->save($productDescription); }