hasMany(Product::class); } public function items() { return $this->belongsToMany(Item::class); } /** * Return the logged in user * * @return \App\User */ public static function loggedIn() { return (new static)->findOrFail(Auth::id()); } /** * Set the default website language * for the acual user * * @param string $language The language code * * @return void */ public static function setLanguage(string $language) { if (Auth::check()) { $user = self::loggedIn(); $user->language = $language; $user->save(); } } }