Esempio n. 1
0
 public function updateAlbum(Request $request)
 {
     $albums = json_decode($request->all()['albums'], true);
     $len = count($albums);
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Album::truncate();
     Photo::truncate();
     Album::reindex();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     foreach ($albums as $a) {
         $album = new Album();
         $album->album_id = $a['id'];
         $album->name = $a['name'];
         $album->created_time = $a['created_time'];
         $album->save();
         $photos = $a['photos']['data'];
         foreach ($photos as $p) {
             $photo = new Photo();
             $photo->album_id = $album->id;
             $photo->photo_id = $p['id'];
             $photo->source = $p['source'];
             $photo->save();
         }
     }
     return '1';
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Unguard
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     //Truncate
     Participant::truncate();
     //Event::truncate();
     Tag::truncate();
     Post::truncate();
     //Image::truncate();
     DB::statement('TRUNCATE `taggables`;');
     //DB::statement('TRUNCATE `imagables`;');
     DB::statement('TRUNCATE `participations`;');
     DB::statement('TRUNCATE `albumables`;');
     Event::reindex();
     Participant::reindex();
     User::reindex();
     Album::reindex();
     //Call
     $this->call(ParticipantTableSeeder::class);
     $this->call(EventTableSeeder::class);
     $this->call(TagTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }