2016-07-21 22:01:57 +08:00
|
|
|
<?php
|
|
|
|
|
2016-08-28 10:05:21 +08:00
|
|
|
namespace App\Http\Controllers;
|
2016-07-21 22:01:57 +08:00
|
|
|
|
2016-08-28 10:05:21 +08:00
|
|
|
use Session;
|
2016-09-24 22:45:54 +08:00
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Support\Arr;
|
2016-09-24 23:37:28 +08:00
|
|
|
use Illuminate\Http\Request;
|
2016-10-23 11:41:52 +08:00
|
|
|
use App\Services\Repositories\UserRepository;
|
2016-07-21 22:01:57 +08:00
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
class HomeController extends Controller
|
2016-07-21 22:01:57 +08:00
|
|
|
{
|
2016-10-23 11:41:52 +08:00
|
|
|
public function index(UserRepository $users, Request $request)
|
2016-07-21 22:01:57 +08:00
|
|
|
{
|
2016-10-23 11:41:52 +08:00
|
|
|
return view('index')->with('user', $users->get(session('uid')));
|
2016-07-21 22:01:57 +08:00
|
|
|
}
|
|
|
|
|
2016-09-24 23:37:28 +08:00
|
|
|
public function locale($lang, Request $request)
|
2016-09-24 22:45:54 +08:00
|
|
|
{
|
|
|
|
if (Arr::exists(config('locales'), $lang)) {
|
|
|
|
Session::set('locale', $lang);
|
|
|
|
}
|
2016-09-24 23:37:28 +08:00
|
|
|
|
|
|
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
|
|
|
return redirect('/')->setTargetUrl($_SERVER['HTTP_REFERER'])->withCookie('locale', $lang);
|
|
|
|
} else {
|
|
|
|
return redirect('/')->withCookie('locale', $lang);
|
|
|
|
}
|
2016-09-24 22:45:54 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 22:01:57 +08:00
|
|
|
}
|