richard
/
cyca
Archived
1
0
Fork 0
This repository has been archived on 2024-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
cyca/app/Providers/LangServiceProvider.php

36 lines
716 B
PHP
Executable File

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class LangServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register()
{
}
/**
* Bootstrap services.
*/
public function boot()
{
view()->composer('*', function ($view) {
$strings = '';
if (auth()->check()) {
$langFile = resource_path(sprintf('lang/%s.json', auth()->user()->lang));
if (file_exists($langFile)) {
$strings = json_decode(file_get_contents($langFile));
}
}
view()->share('langStrings', $strings);
});
}
}