mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
locale + exam assign and checkout cronjob
This commit is contained in:
@@ -63,5 +63,6 @@ class Kernel extends HttpKernel
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'permission' => \App\Http\Middleware\Permission::class,
|
||||
'locale' => \App\Http\Middleware\Locale::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class Locale
|
||||
{
|
||||
public static $languageMaps = [
|
||||
'en' => 'en',
|
||||
'chs' => 'zh_CN',
|
||||
'cht' => 'zh_TW',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$language = $request->user()->language;
|
||||
$locale = self::$languageMaps[$language->site_lang_folder] ?? 'en';
|
||||
do_log("set locale: " . $locale);
|
||||
App::setLocale($locale);
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class Permission
|
||||
do_log("$log, denied!");
|
||||
throw new UnauthorizedException('Unauthorized!');
|
||||
}
|
||||
do_log("$log, pass!");
|
||||
do_log("$log, allow!");
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ class ExamUserResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'status' => $this->status,
|
||||
'status_text' => $this->statusText,
|
||||
'created_at' => formatDatetime($this->created_at),
|
||||
'created_at' => format_datetime($this->created_at),
|
||||
'progress' => $this->when($this->progress, $this->progress),
|
||||
'progress_formatted' => $this->when($this->progress_formatted, $this->progress_formatted),
|
||||
'begin' => formatDatetime($this->begin),
|
||||
'end' => formatDatetime($this->end),
|
||||
'begin' => format_datetime($this->begin),
|
||||
'end' => format_datetime($this->end),
|
||||
'uid' => $this->uid,
|
||||
'exam_id' => $this->exam_id,
|
||||
'user' => new UserResource($this->whenLoaded('user')),
|
||||
|
||||
@@ -19,7 +19,7 @@ class UserResource extends JsonResource
|
||||
'email' => $this->email,
|
||||
'username' => $this->username,
|
||||
'status' => $this->status,
|
||||
'added' => formatDatetime($this->added),
|
||||
'added' => format_datetime($this->added),
|
||||
'class' => $this->class,
|
||||
'class_text' => $this->class_text,
|
||||
'avatar' => $this->avatar,
|
||||
|
||||
Reference in New Issue
Block a user