/** * Show the form for creating a new resource. * * @param Store $store * @return Response */ public function import(Store $store) { // return ['success' => rand(0,1), 'message' => Factory::create()->text(100)]; try { $customer = OsCustomer::findOrFail(Input::get('resource_id')); $result = $store->createCustomer($customer->toWooCommerce()); if (isset($result->customer)) { $imported = ImportedCustomer::create(['os_id' => $customer->customers_id, 'email' => $result->customer->email, 'wc_id' => $result->customer->id]); return ['success' => 1, 'message' => "Customer '{$imported['email']}' imported successfully"]; } } catch (Exception $e) { ErrorCustomer::create(['os_id' => $customer->customers_id, 'email' => $customer->customers_email_address, 'error' => $e->getMessage()]); return ['success' => 0, 'message' => $e->getMessage()]; } return $result; }
<?php use App\Importer\Customer\OsCustomer; get('/', function () { return view('home'); }); get('/changemail', function () { $customers = OsCustomer::where('customers_id', '<', 25000)->where('customers_id', '>', 19999)->get(); $faker = new \Faker\Factory(); foreach ($customers as $customer) { $customer->customers_email_address = $faker->create()->email; $customer->customers_firstname = $faker->create()->firstName; $customer->customers_lastname = $faker->create()->lastName; $customer->save(); } echo "done"; }); post('products', 'ProductController@import'); post('customers', 'CustomerController@import'); post('orders', 'OrderController@import'); post('orders/update', 'OrderController@update'); post('customers/update', 'CustomerController@update'); get('products', 'ProductController@index'); get('products/imported', 'ProductController@imported'); get('products/errors', 'ProductController@errors'); get('customers', 'CustomerController@index'); get('customers/imported', 'CustomerController@imported'); get('customers/errors', 'CustomerController@errors'); get('orders', 'OrderController@index'); get('orders/update', 'OrderController@dates'); get('customers/update', 'CustomerController@points');