public function run() { $faker = Faker::create(); foreach (range(1, 100) as $index) { $client = Client::create(['name' => $faker->company, 'about' => $faker->sentence(), 'location' => $faker->city . ' ' . $faker->state, 'industry_id' => $faker->numberBetween(1, 10), 'agency_id' => $faker->numberBetween(1, 10)]); $staff = ClientStaff::create(['name' => $faker->firstName . ' ' . $faker->lastName, 'email' => $faker->email, 'type' => 'hr', 'client_id' => $client->id, 'telephone' => $faker->randomNumber(6)]); } }
/** * Create Client * @return \Illuminate\Http\JsonResponse */ public function create() { $success = false; if ($this->validator->validate(\Input::all())) { Log::info(Input::all()); $client = Client::create(\Input::all()); $success = $client == true; // Destination path for uplaoded files which is at /public/uploads $destinationPath = public_path() . '/uploads/img/'; // Handle profile Picture if (Input::hasFile('logo_filename')) { $file = Input::file('logo_filename'); $logo_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName()); $uploadSuccess = $file->move($destinationPath, $logo_filename); if ($uploadSuccess) { $client->logo_filename = $logo_filename; $client->save(); } } } return \Response::json(['success' => $success]); }