public function actionClear()
    {
        $query = AttachmentFile::find()->temporary();

        foreach ($query->batch(10) as $models) {
            /** @var AttachmentFile $model */
            foreach ($models as $model) {
                $url = $model->filePath;

                if ($model->delete()) {
                    $this->stdout('File ');
                    $this->stdout($url, Console::FG_YELLOW);
                    $this->stdout(' deleted');
                    echo PHP_EOL;
                }
            }
        }
    }
public function actionClear()
    {
        $query = AttachmentFile::find()->temporary();

        foreach ($query->batch(10) as $models) {
            /** @var AttachmentFile $model */
            foreach ($models as $model) {
                $url = $model->filePath;

                if ($model->delete()) {
                    $this->stdout('File ');
                    $this->stdout($url, Console::FG_YELLOW);
                    $this->stdout(' deleted');
                    echo PHP_EOL;
                }
            }
        }
    }
public function actionClear ( ) { $ query = AttachmentFile :: find ( ) -> temporary ( ) ; foreach ( $ query -> batch ( 10 ) as $ models ) { /** @var AttachmentFile $model */ foreach ( $ models as $ model ) { $ url = $ model -> filePath ; if ( $ model -> delete ( ) ) { $ this -> stdout ( 'File ' ) ; $ this -> stdout ( $ url , Console :: FG_YELLOW ) ; $ this -> stdout ( ' deleted' ) ; echo PHP_EOL ; } } } }
Clear temporary files
Clear temporary files