I intend that when today's date is equal to 2022-08-01, the function is no longer executed

Hello guys,
I need help with the following question. I have the following function,

    public function actionView($id)
    {
        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }

I intend that when today’s date is equal to 2022-08-01, the function is no longer executed, showing a message of the type “Date exceeded to execute the function”.
Thank you so much…

Just add the check in action before rendering view or before the action is called using access control and throw the error or redirect to other action with message.