Ejemplo n.º 1
0
 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();
     }
 }
 /**
  * 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!');
 }
Ejemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StateRequest $request)
 {
     /** save data from State form to database **/
     $model = new State();
     $model->name = $request->get('name');
     $model->status = $request->get('status');
     $model->save();
     return redirect('state');
 }
Ejemplo n.º 4
0
 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;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(LocationCreateRequest $request)
 {
     $state = $request->input('state');
     if (!($existingState = State::where('id', $state)->first())) {
         $newState = new State();
         $newState->name = $state;
         $newState->save();
     }
     $locs = $request->input('lga');
     foreach ($locs as $loc) {
         $area = new Lga();
         $area->name = $loc;
         $area->state_id = $newState->id;
         $area->save();
     }
     return redirect('/admin/location')->withSuccess("Area created.");
 }
Ejemplo n.º 6
0
 public function run()
 {
     DB::statement("TRUNCATE TABLE states CASCADE");
     $state = new State(['abbr' => 'AC', 'name' => 'Acre']);
     $state->id = 12;
     $state->save();
     $state = new State(['abbr' => 'AL', 'name' => 'Alagoas']);
     $state->id = 27;
     $state->save();
     $state = new State(['abbr' => 'AP', 'name' => 'Amapá']);
     $state->id = 16;
     $state->save();
     $state = new State(['abbr' => 'AM', 'name' => 'Amazonas']);
     $state->id = 13;
     $state->save();
     $state = new State(['abbr' => 'BA', 'name' => 'Bahia']);
     $state->id = 29;
     $state->save();
     $state = new State(['abbr' => 'CE', 'name' => 'Ceará']);
     $state->id = 23;
     $state->save();
     $state = new State(['abbr' => 'DF', 'name' => 'Distrito Federal']);
     $state->id = 53;
     $state->save();
     $state = new State(['abbr' => 'ES', 'name' => 'Espírito Santo']);
     $state->id = 32;
     $state->save();
     $state = new State(['abbr' => 'GO', 'name' => 'Goiás']);
     $state->id = 52;
     $state->save();
     $state = new State(['abbr' => 'MA', 'name' => 'Maranhão']);
     $state->id = 21;
     $state->save();
     $state = new State(['abbr' => 'MT', 'name' => 'Mato Grosso']);
     $state->id = 51;
     $state->save();
     $state = new State(['abbr' => 'MS', 'name' => 'Mato Grosso do Sul']);
     $state->id = 50;
     $state->save();
     $state = new State(['abbr' => 'MG', 'name' => 'Minas Gerais']);
     $state->id = 31;
     $state->save();
     $state = new State(['abbr' => 'PA', 'name' => 'Pará']);
     $state->id = 15;
     $state->save();
     $state = new State(['abbr' => 'PB', 'name' => 'Paraíba']);
     $state->id = 25;
     $state->save();
     $state = new State(['abbr' => 'PR', 'name' => 'Paraná']);
     $state->id = 41;
     $state->save();
     $state = new State(['abbr' => 'PE', 'name' => 'Pernambuco']);
     $state->id = 26;
     $state->save();
     $state = new State(['abbr' => 'PI', 'name' => 'Piauí']);
     $state->id = 22;
     $state->save();
     $state = new State(['abbr' => 'RJ', 'name' => 'Rio de Janeiro']);
     $state->id = 33;
     $state->save();
     $state = new State(['abbr' => 'RN', 'name' => 'Rio Grande do Norte']);
     $state->id = 24;
     $state->save();
     $state = new State(['abbr' => 'RS', 'name' => 'Rio Grande do Sul']);
     $state->id = 43;
     $state->save();
     $state = new State(['abbr' => 'RO', 'name' => 'Rondônia']);
     $state->id = 11;
     $state->save();
     $state = new State(['abbr' => 'RR', 'name' => 'Roraima']);
     $state->id = 14;
     $state->save();
     $state = new State(['abbr' => 'SC', 'name' => 'Santa Catarina']);
     $state->id = 42;
     $state->save();
     $state = new State(['abbr' => 'SP', 'name' => 'São Paulo']);
     $state->id = 35;
     $state->save();
     $state = new State(['abbr' => 'SE', 'name' => 'Sergipe']);
     $state->id = 28;
     $state->save();
     $state = new State(['abbr' => 'TO', 'name' => 'Tocantins']);
     $state->id = 17;
     $state->save();
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PostCreateRequest $request)
 {
     //dd(\Input::all());
     $post = new Post();
     $post->title = $request->get('title');
     $post->company_name = $request->get('company');
     $date = $request->get('closing');
     //dd(date('Y-m-d', strtotime($date)));
     $post->closing = date('Y-m-d', strtotime($date));
     $post->job_description = $request->get('job_description');
     $post->job_experience = $request->get('job_experience');
     $post->company_description = $request->get('company_description');
     $post->salary = $request->get('salary');
     $publish = $request->get('publish');
     $save = $request->get('save');
     $state = $request->get('location');
     $cat = $request->get('category');
     $tags = $request->get('tags');
     $tagNames = [];
     foreach ($tags as $tag) {
         if ($existingTag = Tag::where('name', $tag)->first()) {
             $TagNames[] = $existingTag;
         } else {
             $newTag = new Tag();
             $newTag->name = $tag;
             $newTag->save();
             $TagNames[] = $newTag;
         }
     }
     if (isset($publish)) {
         $post->active = 1;
         $post->save();
         $post->tags()->saveMany($TagNames);
         $newCat = new Category();
         $newCat->name = $cat;
         $newCat->post_id = $post->id;
         $newCat->save();
         // $post->tags()->sync($tag);
         $sta = new State();
         $sta->name = $state;
         $sta->post_id = $post->id;
         $sta->save();
         return redirect('admin')->withSuccess("New job has been published");
     } else {
         if (isset($save)) {
             $post->active = 0;
             $post->save();
             $post->tags()->saveMany($TagNames);
             $newCat = new Category();
             $newCat->name = $cat;
             $newCat->post_id = $post->id;
             $newCat->save();
             // $post->tags()->sync($tag);
             $sta = new State();
             $sta->name = $state;
             $sta->post_id = $post->id;
             $sta->save();
             return redirect('/admin')->withErrors("The post has been saved for publishing later");
         }
     }
     // dd(strip_tags($raw));
 }