action = $action; $this->request = $request; $this->model = $parser; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Parser $parser, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $parser = $parser->create($attributes); return $parser; } public function update(Parser $parser, array $request) { $attributes = $request; $parser->update($attributes); return $parser; } public function destroy(Parser $parser, array $request) { $parser->delete(); return $parser; } public function copy(Parser $parser, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $parser = $parser->replicate(); $parser->created_at = Carbon::now(); $parser->save(); return $parser; } for ($i = 1; $i <= $count; $i++) { $new = $parser->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $parser; } }