binshops / laravel-blog

Laravel Blog Package/ Laravel CMS. Easiest way to add a blogging system to your Laravel website. Laravel Blog.
https://www.binshops.com
MIT License
429 stars 134 forks source link

Trying to get property 'locale' of non-object #64

Closed hasnainali9 closed 2 years ago

hasnainali9 commented 2 years ago

namespace BinshopsBlog\Middleware;

use Closure;

use BinshopsBlog\Models\BinshopsConfiguration;

use BinshopsBlog\Models\BinshopsLanguage;

class LoadLanguage

{

public function handle($request, Closure $next)

{

    $default_locale = BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE');

    $lang = BinshopsLanguage::where('locale', $default_locale)

        ->first();

    $request->attributes->add([

        **'locale' => $lang->locale,**

        'language_id' => $lang->id

    ]);

    return $next($request);

}

}

samberrry commented 2 years ago

Hi, it seems that you have not set up the package. thanks