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