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'])); }
/** * @param $column * @param $value * @param array|null $related * @return mixed */ public function getWhere($column, $value, array $related = null) { return $this->model->where($column, $value)->first(); }