-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathweb.php
executable file
·40 lines (37 loc) · 1.41 KB
/
web.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/js/lang', function () {
if (App::environment('local'))
Cache::forget('lang.js');
$strings = Cache::rememberForever('lang.js', function () {
$lang = config('app.locale');
$files = glob(resource_path('lang/' . $lang . '/*.php'));
$strings = [];
foreach ($files as $file) {
$name = basename($file, '.php');
$strings[$name] = require $file;
}
return $strings;
});
header('Content-Type: text/javascript');
echo('window.i18n = ' . json_encode($strings) . ';');
exit();
})->name('assets.lang');
Route::get('/{vue?}', function () {
if(Crawler::isCrawler()) {
$category = App\Category::where('slug', Request::segment(1))->first();
if (empty($category)) return view('seo')->with('article', null);
$article = App\Post::filterByCategoryAndSlug($category, Request::segment(2))->first();
return view('seo')->with('article', $article);
}
return view('home');
})->where('vue', '[\/\w\.-]*')->name('home');