Пример #1
0
 public function run()
 {
     DB::table('amenities')->delete();
     $success = File::cleanDirectory($this->getImagesPath());
     File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore'));
     Amenitie::create(['name' => 'Lobby', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin finibus congue pellentesque. Vestibulum euismod non dolor eget malesuada. Fusce fringilla non nunc ac eleifend. Aliquamauctor cursus lectus sit amet vulputate.', 'image_name' => $this->copyImage(public_path() . '/backup_images/amenities/lobby.jpg'), 'order_id' => 1]);
     Amenitie::create(['name' => 'Lounge', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin finibus congue pellentesque. Vestibulum euismod non dolor eget malesuada. Fusce fringilla non nunc ac eleifend. Aliquamauctor cursus lectus sit amet vulputate.', 'image_name' => $this->copyImage(public_path() . '/backup_images/amenities/lounge.jpg'), 'order_id' => 2]);
     Amenitie::create(['name' => 'Terrace', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin finibus congue pellentesque. Vestibulum euismod non dolor eget malesuada. Fusce fringilla non nunc ac eleifend. Aliquamauctor cursus lectus sit amet vulputate.', 'image_name' => $this->copyImage(public_path() . '/backup_images/amenities/terrace.jpg'), 'order_id' => 3]);
     Amenitie::create(['name' => 'Children\'s Playroom', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin finibus congue pellentesque. Vestibulum euismod non dolor eget malesuada. Fusce fringilla non nunc ac eleifend. Aliquamauctor cursus lectus sit amet vulputate.', 'image_name' => $this->copyImage(public_path() . '/backup_images/amenities/childrens_playroom.jpg')]);
     Amenitie::create(['name' => 'Other amenities', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin finibus congue pellentesque. Vestibulum euismod non dolor eget malesuada. Fusce fringilla non nunc ac eleifend. Aliquamauctor cursus lectus sit amet vulputate.', 'image_name' => $this->copyImage(public_path() . '/backup_images/amenities/other_amenities.jpg')]);
 }
Пример #2
0
 public function getAmenities()
 {
     $amenities = Amenitie::orderBy('order_id')->get();
     return View::make('site.amenities', array('amenities' => $amenities));
 }
Пример #3
0
 public function updateSortableElements($type)
 {
     $ids = Input::get('item');
     if ($type == 'amenities') {
         for ($i = 0; $i < count($ids); $i++) {
             $amenitie = Amenitie::where('id', '=', $ids[$i])->first();
             var_dump($amenitie->toJson());
             $amenitie->update(array('order_id' => $i + 1));
         }
     } else {
         if ($type == 'residences') {
             for ($i = 0; $i < count($ids); $i++) {
                 $residence = Residence::where('id', '=', $ids[$i])->first();
                 $residence->update(array('order_id' => $i + 1));
             }
         } else {
             if ($type == 'home') {
                 for ($i = 0; $i < count($ids); $i++) {
                     $residence = HomePage::where('id', '=', $ids[$i])->first();
                     $residence->update(array('order_id' => $i + 1));
                 }
             } else {
                 if ($type == 'terrace') {
                     for ($i = 0; $i < count($ids); $i++) {
                         $residence = TerraceLivingPage::where('id', '=', $ids[$i])->first();
                         $residence->update(array('order_id' => $i + 1));
                     }
                 } else {
                     echo 'Non sortable type';
                 }
             }
         }
     }
 }