mercredi 3 juin 2020

Syntax error, unexpected in Laravel query

I am beginner in Laravel. I have this code:

public function getFilesArray(int $id, string $type, int $fileCategory)
    {
        return $this->model
            ->where(function() {
                if(auth()->user()->getRoleNames()->first() != "superadmin"){
                    ->where('company_id', Auth::user()->company_id);
                }
            })
            ->active()
            ->where('file_id', $id)
            ->where('file_type', '=', $type)
            ->orderBy('order', 'asc')
            ->get();
    }

I have error in line:

if(auth()->user()->getRoleNames()->first() != "superadmin"){

"Excepting statement" (PHP Storm) or on website: syntax error, unexpected '->' (T_OBJECT_OPERATOR)

How can I repair it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire