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