|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File of Main Controller of NOJ |
|
4
|
|
|
* php version 7.2.10 |
|
5
|
|
|
* |
|
6
|
|
|
* @category NOJ |
|
7
|
|
|
* @package MainController |
|
8
|
|
|
* @author John Zhang <[email protected]> |
|
9
|
|
|
* @license https://github.com/ZsgsDesign/NOJ/blob/master/LICENSE MIT |
|
10
|
|
|
* @link https://github.com/ZsgsDesign/NOJ/ GitHub |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace App\Http\Controllers; |
|
13
|
|
|
|
|
14
|
|
|
use App\Models\Eloquent\Announcement; |
|
15
|
|
|
use App\Models\ProblemModel; |
|
16
|
|
|
use App\Models\Eloquent\Carousel; |
|
17
|
|
|
use App\Http\Controllers\Controller; |
|
18
|
|
|
use Illuminate\Http\Request; |
|
19
|
|
|
use Auth; |
|
20
|
|
|
use Log; |
|
21
|
|
|
use Redirect; |
|
22
|
|
|
use Cache; |
|
23
|
|
|
/** |
|
24
|
|
|
* Main Controller of NOJ |
|
25
|
|
|
* |
|
26
|
|
|
* @category NOJ |
|
27
|
|
|
* @package MainController |
|
28
|
|
|
* @author John Zhang <[email protected]> |
|
29
|
|
|
* @license https://github.com/ZsgsDesign/NOJ/blob/master/LICENSE MIT |
|
30
|
|
|
* @link https://github.com/ZsgsDesign/NOJ/ GitHub |
|
31
|
|
|
*/ |
|
32
|
|
|
class MainController extends Controller |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* Show the Home Page. |
|
36
|
|
|
* |
|
37
|
|
|
* @param Request $request your web request |
|
38
|
|
|
* |
|
39
|
|
|
* @return Response |
|
|
|
|
|
|
40
|
|
|
*/ |
|
41
|
|
|
public function home(Request $request) |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$problem=new ProblemModel(); |
|
44
|
|
|
$ojs=$problem->ojs(); |
|
45
|
|
|
// Log::debug(["info"=>"User Viewed Home!"]); |
|
46
|
|
|
return view('home', [ |
|
|
|
|
|
|
47
|
|
|
'page_title'=>"Home", |
|
48
|
|
|
'site_title'=>config("app.name"), |
|
49
|
|
|
'navigation' => "Home", |
|
50
|
|
|
'announcements' => Announcement::orderBy('created_at', 'desc')->get(), |
|
51
|
|
|
'ojs' => $ojs, |
|
52
|
|
|
'carousel' => Carousel::where('available', 1)->orderBy('updated_at', 'desc')->get() |
|
53
|
|
|
]); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
public function oldRedirect(Request $request) |
|
58
|
|
|
{ |
|
59
|
|
|
$all_data=$request->all(); |
|
60
|
|
|
$method=isset($all_data["method"]) ? $all_data["method"] : null; |
|
61
|
|
|
$id=isset($all_data["id"]) ? $all_data["id"] : null; |
|
62
|
|
|
if ($method=="showdetail" && !is_null($id)) { |
|
63
|
|
|
$problemModel=new ProblemModel(); |
|
64
|
|
|
return ($problemModel->existPCode("NOJ$id")) ?Redirect::route('problem.detail', ['pcode' => "NOJ$id"]) : Redirect::route('problem.index'); |
|
65
|
|
|
} |
|
66
|
|
|
return Redirect::route('home'); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|