Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/Controller/Admin/Content/ActionClear.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Apps\Controller\Admin\Content;
4
5
use Apps\ActiveRecord\Content as ContentEntity;
6
use Apps\Model\Admin\Content\FormContentClear;
7
use Ffcms\Core\App;
8
use Ffcms\Core\Arch\View;
9
use Ffcms\Core\Network\Request;
10
use Ffcms\Core\Network\Response;
11
12
/**
13
 * Trait ActionClear
14
 * @package Apps\Controller\Admin\Content
15
 * @property Request $request
16
 * @property Response $response
17
 * @property View $view
18
 */
19
trait ActionClear
20
{
21
    /**
22
     * Clear all trashed items
23
     * @return string
24
     * @throws \Ffcms\Core\Exception\SyntaxException
25
     */
26
    public function clear(): ?string
27
    {
28
        // find trashed rows
29
        $records = ContentEntity::onlyTrashed();
30
31
        // init model
32
        $model = new FormContentClear($records);
0 ignored issues
show
It seems like $records can also be of type Illuminate\Database\Eloquent\Builder; however, parameter $records of Apps\Model\Admin\Content...entClear::__construct() does only seem to accept Apps\ActiveRecord\Conten...ase\Eloquent\Collection, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        $model = new FormContentClear(/** @scrutinizer ignore-type */ $records);
Loading history...
33
        if ($model->send() && $model->validate()) {
34
            $model->make();
35
            App::$Session->getFlashBag()->add('success', __('Trash content is cleaned'));
36
            $this->response->redirect('content/index');
37
        }
38
39
        // draw response
40
        return $this->view->render('content/content_clear', [
41
            'model' => $model
42
        ]);
43
    }
44
}
45