Home > Net >  why i get this Error in Laravel file please help me
why i get this Error in Laravel file please help me

Time:12-23

I can not find the error please help me the error is the following :

I can really not find out how to fix it please help me as beginner :)

i did google but still i can not fix it! I can not find the error please help me the error is the following :

I can really not find out how to fix it please help me as beginner :)

i did google but still i can not fix it!

ParseError syntax error, unexpected '@', expecting function (T_FUNCTION) or const (T_CONST)

<?php

namespace App\Http\Controllers\Auth;

use App\Setting;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    /**
     * Where to redirect users after resetting their password.
     *
     * 
     */
     @var string
    protected $redirectTo = RouteServiceProvider::HOME;

    public function __construct()
    {
        if(Auth::check() && Auth::user()->role_id == 1){
            $this->redirectTo = route('admin.dashboard');
        }
         elseif(Auth::check() && Auth::user()->role_id == 2){
            $this->redirectTo = route('user.dashboard');
        }

        $this->middleware('guest')->except('logout');
    }

    protected function redirectTo()
    {
        return '/user/dashboard';
    }

    public function showResetForm($token)
    {
        $config = DB::table('config')->get();
        $settings = Setting::first();

        $google_configuration = [
            'GOOGLE_ENABLE' => env('GOOGLE_ENABLE', ''),
            'GOOGLE_CLIENT_ID' => env('GOOGLE_CLIENT_ID', ''),
            'GOOGLE_CLIENT_SECRET' => env('GOOGLE_CLIENT_SECRET', ''),
            'GOOGLE_REDIRECT' => env('GOOGLE_REDIRECT', '')
        ];
    
        $settings['google_configuration'] = $google_configuration;

        return view('auth.passwords.reset',compact('config', 'token', 'settings'));
    }

}
code

thanks a lot if someone can help me i am a beginner in laravel or php

CodePudding user response:

the problem is @var string remove that

CodePudding user response:

@var string

at the top of

protected $redirectTo = RouteServiceProvider::HOME; 

isn't it suppose to be inside comment?

CodePudding user response:

This line:

 @var string

Is a phpDoc attribute (used to explain the code) that has somehow been removed from the comment block above it.

Move it back into the comment block like so:

/**
  * Where to redirect users after resetting their password.
  *
  * @var string
  */
protected $redirectTo = RouteServiceProvider::HOME;
  • Related