Exemplo n.º 1
0
 public function test(PatternRepository $repository)
 {
     $pattern = $repository->getRandom();
     $pattern_prefix = array_map(function ($item) use($pattern) {
         return ['pattern_id' => $pattern->id, 'prefix_id' => $item];
     }, $pattern->prefixes()->lists('id')->all());
     dd($pattern_prefix);
     dd($repository->getRandom());
     $pattern = Pattern::random()->first();
     $pattern_prefix = array_map(function ($item) use($pattern) {
         return ['pattern_id' => $pattern->id, 'prefix_id' => $item];
     }, $pattern->prefixes()->lists('id')->all());
     $data = ['regex' => '/new_shit/ui', 'section_ids' => [60, 63, 1], 'prefix_ids' => [1, 3, 5]];
     $pattern = $service->create($data);
     dd($pattern);
     dd(Regex::whereId(1)->with(['patterns.sections', 'patterns.prefixes']));
 }
Exemplo n.º 2
0
 public function getRandom()
 {
     return $this->model->random()->first();
 }