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