예제 #1
0
 public function run()
 {
     $params = Parameter::lists('id');
     $tags = Tag::all();
     foreach ($tags as $tag) {
         $tag->params()->attach($randValues = array_intersect_key($params, array_flip(array_rand($params, 2))));
     }
 }
예제 #2
0
 public function run()
 {
     $imgs = Image::lists('id');
     $tags = Tag::all();
     foreach ($tags as $tag) {
         $tag->images()->attach($randValues = array_intersect_key($imgs, array_flip(array_rand($imgs, 2))));
     }
 }
예제 #3
0
 public function run()
 {
     $options = Option::lists('id');
     $tags = Tag::all();
     foreach ($tags as $tag) {
         $tag->options()->attach($randValues = array_intersect_key($options, array_flip(array_rand($options, 2))));
     }
 }
예제 #4
0
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('tags', function ($slug) {
         return Tag::where('slug', $slug)->firstOrFail();
     });
     $router->bind('options', function ($slug) {
         return Option::where('slug', $slug)->firstOrFail();
     });
     $router->bind('parameters', function ($slug) {
         return Parameter::where('slug', $slug)->firstOrFail();
     });
 }
예제 #5
0
 private function deleteImages($id)
 {
     $files = [];
     $files = glob(storage_path() . '/tag_images/*-' . $id . '.jpg');
     if (count($files) > 0) {
         foreach ($files as $file) {
             unlink($file);
         }
     }
     $tag = Tag::find($id);
     $tag->images()->delete();
 }