function store(Request $request) { $input = $request->all(); $testArr = array(); $getParam = Parameter::where('name', '=', $input['parameter'])->first(); if (!empty($getParam)) { $testArr['parameter_id'] = $getParam->id; } else { $parameter = new Parameter(); $parameter->create(array('name' => $input['parameter'])); $testArr['parameter_id'] = DB::getPdo()->lastInsertId(); } $getState = Parameter::where('name', '=', $input['state'])->first(); if (!empty($getState)) { $testArr['state_id'] = $getState->id; } else { $state = new State(); $state->create(array('name' => $input['state'])); $testArr['state_id'] = DB::getPdo()->lastInsertId(); } $getMethod = Method::where('name', '=', $input['method'])->first(); if (!empty($getMethod)) { $testArr['method_id'] = $getMethod->id; } else { $method = new Method(); $method->create(array('name' => $input['method'])); $testArr['method_id'] = DB::getPdo()->lastInsertId(); } $getTestMethod = TestMethod::where('name', '=', $input['test_method'])->first(); if (!empty($getTestMethod)) { $testArr['test_method_id'] = $getTestMethod->id; } else { $tmethod = new TestMethod(); $tmethod->create(array('name' => $input['test_method'])); $testArr['test_method_id'] = DB::getPdo()->lastInsertId(); } $checkTest = Test::where('parameter_id', '=', $testArr['parameter_id'])->where('parameter_id', '=', $testArr['state_id'])->where('parameter_id', '=', $testArr['method_id'])->where('parameter_id', '=', $testArr['test_method_id'])->first(); if ($checkTest) { $test_id = $checkTest->id; Session::flash('flash_message', 'Test already exist.'); } else { $testArr['price'] = 147; $test = new Test(); $test::create($testArr); $test_id = DB::getPdo()->lastInsertId(); Session::flash('flash_message', 'Test created successfully.'); } if ($test_id) { DB::table('test_processes')->where('test_id', '=', $test_id)->delete(); if ($request->has('test_item')) { $items = $request->get('test_item'); foreach ($items as $key => $value) { $process = new Process(); $process::create(array('test_id' => $test_id, 'item_id' => $value, 'status' => 1)); } } } Session::flash('flash_type', 'alert-success'); return redirect('admin/tests'); }
/** * Run the database seeds. * * @return void */ public function run() { // Model::unguard(); //create a user $user = new User(); $user->email = "*****@*****.**"; $user->password = Hash::make('password'); $user->save(); //create a country $country = new Country(); $country->name = "United States"; $country->id = 236; $country->save(); //create a state $state = new State(); $state->name = "Pennsylvania"; $state->id = 1; $state->save(); $city = new City(); $city->name = "Pittsburgh"; $city->id = 1; $city->save(); //create a location $location = new Location(); $location->city_id = $city->id; $location->state_id = $state->id; $location->country_id = $country->id; $location->latitude = 40.44; $location->longitude = 80; $location->code = '15212'; $location->address_1 = "100 Main Street"; $location->save(); //create a new accommodation $accommodation = new Accommodation(); $accommodation->name = "Royal Plaza Hotel"; $accommodation->location_id = $location->id; // $location->id; $accommodation->description = "A modern, 4-star hotel"; $accommodation->save(); //create a room $room1 = new App\Room(); $room1->id = 1; $room1->room_number = 'A01'; $room1->accommodation_id = $accommodation->id; $room1->save(); //create another room $room2 = new Room(); $room2->id = 2; $room2->room_number = 'A02'; $room2->accommodation_id = $accommodation->id; $room2->save(); //create the room array $rooms = [$room1, $room2]; //$this->call('AuthorsTableSeeder'); //$this->command->info('Authors table seeded!'); // $this->call(AmenityTableSeeder::class); $this->command->info('Amenity Class Seeded table seeded!'); }
public static function findOrCreate($data) { $state = self::where('name', $data['state'])->first(); if (count($state) <= 0) { $state = new State(); $state->name = $data['state']; $state->country_id = Country::findOrCreate($data)->id; $state->save(); } return $state; }
/** * Display a listing of the resource. * * @return Response */ public function state(Request $request) { if ($request->ajax()) { $state = State::where('company_id', Auth::user()->company_id)->where('account_year_id', session('account'))->find($request->get('state'))->district()->orderBy('name')->lists('name', 'id'); return $state; } }
public function getList(Request $request) { $data = []; $data += [0 => '-- Selecciona Estado --']; $data += State::where('country_id', $request->country_id)->lists('name', 'id')->toArray(); return $data; }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $country = Country::find($request->country_id); $city = City::find($request->city_id); $state = State::find($request->state_id); return ['country' => $country->name, 'city' => $city->name, 'state' => $state->name]; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $cats = Cat::all(); $bizs = Biz::all(); $states = State::all(); return view('admin.index', compact('biz', 'states', 'featured'))->withCats($cats); }
/** * Bootstrap any application services. * * @return void */ public function boot() { $faults = Attendfault::where('attended', '=', 'No')->get(); $months = Month::all(); $states = State::all(); View::share(['counts' => $faults, 'states' => $states, 'months' => $months]); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($course_id, $schedule_id) { $schedule = Schedule::findOrFail($schedule_id); $schedule_statuses = ScheduleStatus::lists('name', 'id'); $states = State::orderBy('name')->lists('name', 'id'); return view('schedules.edit', compact('schedule', 'states', 'schedule_statuses')); }
public function completeItem($id) : JsonResponse { $status = Nullable::fromValue($id)->reject('')->map('intval')->filter(P::lt(0))->flatMap(Item::class . '::findNullable')->map(function ($item) { return $item->setStateId(State::of('completed')->id)->save(); })->getOrThrow(new \RuntimeException("Item by ID {$id} not found!")); return response()->json(['status' => $status, 'id' => $id]); }
public function ajax(Request $request) { if ($request->mode === 'update') { $states = State::find($request->id); if ($states->state === 1) { $states->state = 0; } else { $states->state = 1; } $states->save(); $state = State::where('id', $request->id)->first(); return response()->json(['state' => $state->state, 'title' => $state->title]); } if ($request->mode === 'create') { if ($request->title) { $states = new State(); $states->title = $request->title; $states->save(); return response()->json(['id' => $states->id]); } } if ($request->mode === 'delete') { $states = State::find($request->id); $states->delete(); } }
public function getStatesForDropdown() { $states = \App\State::orderby('id', 'ASC')->get(); $states_for_dropdown = []; foreach ($states as $state) { $states_for_dropdown[$state->id] = $state->name; } return $states_for_dropdown; }
private function getStates() { $states_rs = State::orderBy('name', 'asc')->get(); $states = [0 => 'Choose a state']; foreach ($states_rs as $s) { $states[$s->abbreviation] = $s->name; } return $states; }
public function run() { DB::table('states')->delete(); State::create(['abr' => 'AL', 'state' => 'Alabama']); State::create(['abr' => 'AK', 'state' => 'Alaska']); State::create(['abr' => 'AZ', 'state' => 'Arizona']); State::create(['abr' => 'AR', 'state' => 'Arkansas']); State::create(['abr' => 'CA', 'state' => 'California']); State::create(['abr' => 'CO', 'state' => 'Colorado']); State::create(['abr' => 'CT', 'state' => 'Connecticut']); State::create(['abr' => 'DE', 'state' => 'Deleware']); State::create(['abr' => 'DC', 'state' => 'District of Columbia']); State::create(['abr' => 'FL', 'state' => 'Florida']); State::create(['abr' => 'GA', 'state' => 'Georgia']); State::create(['abr' => 'HI', 'state' => 'Hawaii']); State::create(['abr' => 'ID', 'state' => 'Idaho']); State::create(['abr' => 'IL', 'state' => 'Illinois']); State::create(['abr' => 'IN', 'state' => 'Indiana']); State::create(['abr' => 'IA', 'state' => 'Iowa']); State::create(['abr' => 'KS', 'state' => 'Kansas']); State::create(['abr' => 'KY', 'state' => 'Kentucky']); State::create(['abr' => 'LA', 'state' => 'Louisiana']); State::create(['abr' => 'ME', 'state' => 'Maine']); State::create(['abr' => 'MD', 'state' => 'Maryland']); State::create(['abr' => 'MA', 'state' => 'Massachusetts']); State::create(['abr' => 'MI', 'state' => 'Michgan']); State::create(['abr' => 'MN', 'state' => 'Minnesota']); State::create(['abr' => 'MS', 'state' => 'Mississippi']); State::create(['abr' => 'MO', 'state' => 'Missouri']); State::create(['abr' => 'MT', 'state' => 'Montana']); State::create(['abr' => 'NE', 'state' => 'Nebraska']); State::create(['abr' => 'NV', 'state' => 'Nevada']); State::create(['abr' => 'NH', 'state' => 'New Hampshire']); State::create(['abr' => 'NJ', 'state' => 'New Jersey']); State::create(['abr' => 'NM', 'state' => 'New Mexico']); State::create(['abr' => 'NY', 'state' => 'New York']); State::create(['abr' => 'NC', 'state' => 'North Carolina']); State::create(['abr' => 'ND', 'state' => 'North Dakota']); State::create(['abr' => 'OH', 'state' => 'Ohio']); State::create(['abr' => 'OK', 'state' => 'Oklahoma']); State::create(['abr' => 'OR', 'state' => 'Oregon']); State::create(['abr' => 'PA', 'state' => 'Pennsylvania']); State::create(['abr' => 'RI', 'state' => 'Rhode Island']); State::create(['abr' => 'SC', 'state' => 'South Carolina']); State::create(['abr' => 'SD', 'state' => 'South Dakota']); State::create(['abr' => 'TN', 'state' => 'Tennessee']); State::create(['abr' => 'TX', 'state' => 'Texas']); State::create(['abr' => 'UT', 'state' => 'Utah']); State::create(['abr' => 'VT', 'state' => 'Vermont']); State::create(['abr' => 'VA', 'state' => 'Virginia']); State::create(['abr' => 'WA', 'state' => 'Washington']); State::create(['abr' => 'WV', 'state' => 'West Virginia']); State::create(['abr' => 'WI', 'state' => 'Wisconsin']); State::create(['abr' => 'WY', 'state' => 'Wyoming']); State::create(['abr' => 'USA', 'state' => 'United States of America']); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { if ($request->has('filterBy')) { $questions = Question::with('state')->where($request->get('filterBy') . '_id', $request->get('id'))->get(); } else { $questions = Question::orderBy('likes', 'desc')->with('state')->get(); } $states = State::lists('name', 'id'); return view('admin.questions.index', compact('questions', 'states')); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|max:255']); $input = $request->all(); $input['company_id'] = Auth::user()->company_id; $input['user_id'] = Auth::user()->id; $input['account_year_id'] = session('account'); State::create($input); flash()->success('State Created Successfully !'); return redirect('state'); }
public function location() { $query = \Input::get('l', ''); if (trim(urldecode($query)) == '') { return \Response::json(['data' => []], 200); } $lga = \App\Lga::where('name', 'like', '%' . $query . '%')->orderBy('name', 'asc')->take(10)->get(['id', 'name'])->toArray(); $state = \App\State::where('name', 'like', '%' . $query . '%')->orderBy('name', 'asc')->take(5)->get(['id', 'name'])->toArray(); $data = array_merge($lga, $state); return \Response::json(['data' => $data]); }
public static function findOrCreate($data) { $city = self::where('name', $data['city'])->first(); if (count($city) <= 0) { $city = new City(); $city->name = $data['city']; $city->state_id = State::findOrCreate($data)->id; $city->save(); } return $city; }
public function update($id) { // save updated $record = $this->records->find($id); if (!$record) { State::create(Input::all()); return $this->respond($record); } $record->fill(Input::all())->save(); return $this->respond($record); }
/** * Run the database seeds. * * @return void */ public function run() { State::create(['country_id' => '', 'name' => '']); State::create(['country_id' => 859, 'id' => 50, 'name' => 'Republica Dominicana']); State::create(['country_id' => 858, 'id' => 33, 'name' => 'Montevideo']); State::create(['country_id' => 840, 'id' => 34, 'name' => 'Utah']); State::create(['country_id' => 840, 'id' => 43, 'name' => 'San Francisco']); State::create(['country_id' => 724, 'id' => 39, 'name' => 'España']); State::create(['country_id' => 604, 'id' => 44, 'name' => 'Lima']); State::create(['country_id' => 604, 'id' => 47, 'name' => 'Lima']); State::create(['country_id' => 600, 'id' => 42, 'name' => 'Asunción']); State::create(['country_id' => 591, 'id' => 37, 'name' => 'Panamá']); State::create(['country_id' => 484, 'id' => 1, 'name' => 'Aguascalientes']); State::create(['country_id' => 484, 'id' => 2, 'name' => 'Baja California']); State::create(['country_id' => 484, 'id' => 3, 'name' => 'Baja California Sur']); State::create(['country_id' => 484, 'id' => 4, 'name' => 'Campeche']); State::create(['country_id' => 484, 'id' => 5, 'name' => 'Coahuila']); State::create(['country_id' => 484, 'id' => 6, 'name' => 'Colima']); State::create(['country_id' => 484, 'id' => 7, 'name' => 'Chiapas']); State::create(['country_id' => 484, 'id' => 8, 'name' => 'Chihuahua']); State::create(['country_id' => 484, 'id' => 9, 'name' => 'Distrito Federal']); State::create(['country_id' => 484, 'id' => 10, 'name' => 'Durango']); State::create(['country_id' => 484, 'id' => 11, 'name' => 'Guanajuato']); State::create(['country_id' => 484, 'id' => 12, 'name' => 'Guerrero']); State::create(['country_id' => 484, 'id' => 13, 'name' => 'Hidalgo']); State::create(['country_id' => 484, 'id' => 14, 'name' => 'Jalisco']); State::create(['country_id' => 484, 'id' => 15, 'name' => 'México']); State::create(['country_id' => 484, 'id' => 16, 'name' => 'Michoacán']); State::create(['country_id' => 484, 'id' => 17, 'name' => 'Morelos']); State::create(['country_id' => 484, 'id' => 18, 'name' => 'Nayarit']); State::create(['country_id' => 484, 'id' => 19, 'name' => 'Nuevo León']); State::create(['country_id' => 484, 'id' => 20, 'name' => 'Oaxaca']); State::create(['country_id' => 484, 'id' => 21, 'name' => 'Puebla']); State::create(['country_id' => 484, 'id' => 22, 'name' => 'Querétaro']); State::create(['country_id' => 484, 'id' => 23, 'name' => 'Quintana Roo']); State::create(['country_id' => 484, 'id' => 24, 'name' => 'San Luis Potosí']); State::create(['country_id' => 484, 'id' => 25, 'name' => 'Sinaloa']); State::create(['country_id' => 484, 'id' => 26, 'name' => 'Sonora']); State::create(['country_id' => 484, 'id' => 27, 'name' => 'Tabasco']); State::create(['country_id' => 484, 'id' => 28, 'name' => 'Tamaulipas']); State::create(['country_id' => 484, 'id' => 29, 'name' => 'Tlaxcala']); State::create(['country_id' => 484, 'id' => 30, 'name' => 'Veracruz']); State::create(['country_id' => 484, 'id' => 31, 'name' => 'Yucatán']); State::create(['country_id' => 484, 'id' => 32, 'name' => 'Zacatecas']); State::create(['country_id' => 340, 'id' => 38, 'name' => 'Francisco Morazán']); State::create(['country_id' => 320, 'id' => 36, 'name' => 'Guatemala']); State::create(['country_id' => 222, 'id' => 40, 'name' => 'San Salvador']); State::create(['country_id' => 218, 'id' => 49, 'name' => 'Pichincha']); State::create(['country_id' => 188, 'id' => 35, 'name' => 'San José']); State::create(['country_id' => 152, 'id' => 48, 'name' => 'Santiago']); State::create(['country_id' => 76, 'id' => 41, 'name' => 'Brasilia']); }
/** * Bootstrap any application services. * * @return void */ public function boot() { /*view()->share('categories', Category::all());*/ view()->composer('layouts.partials.categories', function ($view) { $view->with('categories', Category::where('parent_id', 0)->get()); }); view()->composer('layouts.partials.states', function ($view) { $view->with('states', State::all()); }); view()->composer('index', function ($view) { $view->with('categories', Category::where('parent_id', 0)->get()); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('states', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); }); State::create(['name' => 'En demande']); State::create(['name' => 'En cours de traitement']); State::create(['name' => 'Déjà traité']); State::create(['name' => 'Disponible']); State::create(['name' => 'Hors sujet']); State::create(['name' => 'Fermé']); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $filename = base_path('public/nigeria.json'); $data = json_decode(file_get_contents($filename), TRUE); foreach ($data as $key => $value) { $state = State::create(array('state' => $key, 'capital' => $value['capital'], 'population' => $value['population'], 'area' => $value['land_area'], 'nickname' => $value['nick_name'], 'date_created' => $value['date_created'], 'preceding_entity' => $value['preceding_entity'], 'lg_count' => $value['lg_count'])); for ($i = 1; $i < count($value['lga']); $i++) { $lga = Lga::create(array('state_id' => $state->id, 'lg_name' => $value['lga'][$i])); } } // $this->call('UserTableSeeder'); Model::reguard(); }
/** * @param Schedule $schedule */ public function saved(Schedule $schedule) { $state_ids = [$schedule->state_id]; $original_state_id = $schedule->getOriginal('state_id'); if ($original_state_id && $original_state_id != $schedule->state_id) { $state_ids[] = $original_state_id; } $stale_files = ['course-schedule-' . $schedule->course_id]; $states = State::whereIn('id', $state_ids)->get(); foreach ($states as $state) { $stale_files[] = 'state-schedule-' . $state->code; } $cache_path = public_path() . '/js/cache'; foreach ($stale_files as $stale_file) { File::delete($cache_path . DIRECTORY_SEPARATOR . $stale_file . '.js'); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('states')->delete(); $json = File::get(storage_path() . '/json/states.json'); $data = json_decode($json); foreach ($data as $k => $v) { if ($k == 'RestResponse') { foreach ($v as $key => $value) { if ($key == 'result') { foreach ($value as $object) { State::create(['country_code' => $object->country, 'state_code' => $object->abbr, 'name' => $object->name, 'capital' => $object->capital]); } } } } } }
public function testRegisterAction() { // use the factory to create a Faker\Generator instance $faker = Faker\Factory::create(); // Add pt_BR provider $faker->addProvider(new Faker\Provider\pt_BR\Person($faker)); //Generate a User Data to Register $name = $faker->name($gender = null | 'male' | 'female'); $email = $faker->freeEmail(); $cpf = $faker->cpf; $pwd = '123456'; $state = State::all()->random(); $uuid = $faker->uuid; // prevent validation error on captcha NoCaptcha::shouldReceive('verifyResponse')->once()->andReturn(true); // provide hidden input for your 'required' validation NoCaptcha::shouldReceive('display')->zeroOrMoreTimes()->andReturn('<input type="hidden" name="g-recaptcha-response" value="1" />'); $this->visit('/')->click('Registro')->seePageIs('/login')->type($name, 'name')->type($email, 'email')->type($cpf, 'cpf')->type($pwd, 'password')->type($pwd, 'password_confirmation')->select($state->uf, 'uf')->type($uuid, 'uuid')->press('Registro')->see('Registro feito com Sucesso.')->seePageIs('/')->seeInDatabase('users', ['email' => $email]); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $state = \App\State::find($id); if ($state) { $rules = \App\State::$rules; //$rules['name'] = 'required|min:2'; $validator = \Validator::make(\Input::all(), $rules); if ($validator->passes()) { $state = \App\State::find($id); $state->name = \Input::get('name'); $state->country_id = \Input::get('country'); $state->save(); flash('State updated.'); return \Redirect::back(); } return \Redirect::back()->withInput()->withErrors($validator); } flash()->error('State does not exist.'); return \Redirect::back(); }
public function postDistricts(Request $request, $nationality_id, $state_id, $lga_id) { $rules = array('title' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return Redirect::to('/place/' . $nationality_id . '/' . $state_id . '/' . $lga_id)->withErrors($validator)->withInput($request->except('password')); } else { $user = new User(); $user->id = 1; //$user = Auth::user(); $record = new District(); $record->title = $request->get('title'); $record->lga()->associate(Lga::find($lga_id)); $record->state()->associate(State::find($state_id)); $record->nationality()->associate(Nationality::find($nationality_id)); $record->user()->associate($user); $record->save(); // redirect Session::flash('message', 'Successfully updated!'); return Redirect::to('/place/' . $nationality_id . '/' . $state_id . '/' . $lga_id); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $data['student'] = Student::find($id); $data['title'] = 'Edit ' . $data['student']->fname; $data['students_menu'] = 1; $data['gender'] = Gender::lists('gender', 'id')->prepend('Please Select'); $data['bloodGroups'] = BloodGroup::lists('blood_group', 'id')->prepend('Please Select'); $data['locals'] = Local::lists('local_name', 'id')->prepend('Please Select'); $data['states'] = State::lists('name', 'id')->prepend('Please Select'); $data['countries'] = Country::lists('name', 'id')->prepend('Please Select'); $data['parents'] = StudentParent::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->lists('full_name', 'id')->prepend('Please Select'); $data['classes'] = StudentClass::lists('name', 'id')->prepend('Please Select'); $data['religions'] = Religion::lists('religion', 'id')->prepend('Please Select'); return view('admin.students.edit', $data); }
public function __construct(Branch $branch, State $state, District $district) { $this->branch = $branch->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); $this->district = $district->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); $this->state = $state->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); }