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