0

I'm facing issue of "Class hash does not exist". I know there are same question related this but these are not enough for me. Here I'm loading routes as per user device. As per mobile I using different routes as shown below:

Route::group(['middleware' => ['web']], function () {

    if(SiteHelpers::isMobileViewEnabled() == true && Mobile::isMobile() == true && Mobile::isTablet() == false){

        require app_path('Http/Routes/mui.php');

    }else{

        require app_path('Http/Routes/desktop.php');
    }

...

Here is SiteHelper code

public static function isMobileViewEnabled()
{
    $isEnabled = false;
    $user = Auth::user();
    $getEnabled = DB::table('setting')->where('setting_name', 'Mobile UI')->first();
    if(isset($getEnabled) && $getEnabled->setting_value==1){
        $isEnabled = true;
    }
    return $isEnabled;

}

When I use

Auth::user()

Than I'm getting error

Class hash does not exist enter image description here

I don't know whats going wrong, Please let me know where I making mistake.

vinod
  • 236
  • 3
  • 11
  • Where have you used Hash? wherever you have used make sure in top after namespace `use Hash;` – Dilip Hirapara Mar 17 '20 at 06:49
  • Yeah! @DilipHirapara I'm using Hash top of the SiteHelpers. – vinod Mar 17 '20 at 06:53
  • Try this use Hash; or https://stackoverflow.com/questions/49141040/uncaught-reflectionexception-class-hash-does-not-exist-in-envoyer-deploy – Waleed Muaz Mar 17 '20 at 06:54
  • You seem to have the required provider there in the list. Try clearing services cache file https://laracasts.com/discuss/channels/laravel/laravel-52-class-hash-does-not-exist – Sehdev Mar 17 '20 at 06:54
  • @Sehdev No its not working for me. When I'm tryting to clear cache its throwing same error. – vinod Mar 17 '20 at 07:00

2 Answers2

0

You seem to have the required provider there in the list. Try clearing services cache file

Dinh Luong
  • 127
  • 3
  • 15
  • No its not working for me. When I'm tryting to clear cache its throwing same error – vinod Mar 17 '20 at 07:00
  • You try check in config/app.php. Have you updated it? Like: `'Hash' => Illuminate\Support\Facades\Hash::class,` – Dinh Luong Mar 17 '20 at 09:00
  • Yes, I have added required service provider in config/app.php. – vinod Mar 17 '20 at 12:11
  • I have refer to some similar issues. Do you have the php mbstring/PDO etc libraries installed properly (have you updated your server recently?) Make sure you have everything from. If you are using Laravel 5.2. Can you refer: https://laravel.com/docs/5.2#server-requirements – Dinh Luong Mar 19 '20 at 06:34
0

This is not the answer for your question but I think it will create issue for you later on so,replace this

if(!is_null($getEnabled) && $getEnabled->setting_value==1){
        $isEnabled = true;
    }

with

if(isset($getEnabled) && $getEnabled->setting_value==1){
        $isEnabled = true;
    }

Because $getEnabled is always set.

Yasir
  • 101
  • 2
  • 11