Skip to content

Commit 2186ec1

Browse files
author
qiyichao
committed
初始化提交项目
0 parents  commit 2186ec1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3969
-0
lines changed

app/Category.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\SoftDeletes;
7+
8+
class Category extends Model
9+
{
10+
11+
use SoftDeletes;
12+
13+
public function paper()
14+
{
15+
return $this->hasMany('App\Paper');
16+
}
17+
}

app/Console/Kernel.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')
28+
// ->hourly();
29+
}
30+
31+
/**
32+
* Register the Closure based commands for the application.
33+
*
34+
* @return void
35+
*/
36+
protected function commands()
37+
{
38+
require base_path('routes/console.php');
39+
}
40+
}

app/Exceptions/Handler.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Auth\AuthenticationException;
7+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8+
9+
class Handler extends ExceptionHandler
10+
{
11+
/**
12+
* A list of the exception types that should not be reported.
13+
*
14+
* @var array
15+
*/
16+
protected $dontReport = [
17+
\Illuminate\Auth\AuthenticationException::class,
18+
\Illuminate\Auth\Access\AuthorizationException::class,
19+
\Symfony\Component\HttpKernel\Exception\HttpException::class,
20+
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
21+
\Illuminate\Session\TokenMismatchException::class,
22+
\Illuminate\Validation\ValidationException::class,
23+
];
24+
25+
/**
26+
* Report or log an exception.
27+
*
28+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29+
*
30+
* @param \Exception $exception
31+
* @return void
32+
*/
33+
public function report(Exception $exception)
34+
{
35+
parent::report($exception);
36+
}
37+
38+
/**
39+
* Render an exception into an HTTP response.
40+
*
41+
* @param \Illuminate\Http\Request $request
42+
* @param \Exception $exception
43+
* @return \Illuminate\Http\Response
44+
*/
45+
public function render($request, Exception $exception)
46+
{
47+
return parent::render($request, $exception);
48+
}
49+
50+
/**
51+
* Convert an authentication exception into an unauthenticated response.
52+
*
53+
* @param \Illuminate\Http\Request $request
54+
* @param \Illuminate\Auth\AuthenticationException $exception
55+
* @return \Illuminate\Http\Response
56+
*/
57+
protected function unauthenticated($request, AuthenticationException $exception)
58+
{
59+
if ($request->expectsJson()) {
60+
return response()->json(['error' => 'Unauthenticated.'], 401);
61+
}
62+
63+
return redirect()->guest('login');
64+
}
65+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Category;
7+
use App\Paper;
8+
9+
class CategoryController extends Controller
10+
{
11+
/**
12+
* Display a listing of the resource.
13+
*
14+
* @return \Illuminate\Http\Response
15+
*/
16+
public function index(Request $request)
17+
{
18+
// 获取分类列表,或者指定分类下的文章
19+
$name = $request->input('name');
20+
if (!empty($name)) {
21+
return Category::where('name', $name)->first();
22+
} else {
23+
// 分类列表
24+
return [
25+
'category' => Category::all()->toArray(),
26+
'page' => Paper::where('page', true)->get()->toArray()
27+
];
28+
}
29+
}
30+
31+
/**
32+
* Show the form for creating a new resource.
33+
*
34+
* @return \Illuminate\Http\Response
35+
*/
36+
public function create()
37+
{
38+
//
39+
}
40+
41+
/**
42+
* Store a newly created resource in storage.
43+
*
44+
* @param \Illuminate\Http\Request $request
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function store(Request $request)
48+
{
49+
//
50+
}
51+
52+
/**
53+
* Display the specified resource.
54+
*
55+
* @param int $id
56+
* @return \Illuminate\Http\Response
57+
*/
58+
public function show($id)
59+
{
60+
//
61+
}
62+
63+
/**
64+
* Show the form for editing the specified resource.
65+
*
66+
* @param int $id
67+
* @return \Illuminate\Http\Response
68+
*/
69+
public function edit($id)
70+
{
71+
//
72+
}
73+
74+
/**
75+
* Update the specified resource in storage.
76+
*
77+
* @param \Illuminate\Http\Request $request
78+
* @param int $id
79+
* @return \Illuminate\Http\Response
80+
*/
81+
public function update(Request $request, $id)
82+
{
83+
//
84+
}
85+
86+
/**
87+
* Remove the specified resource from storage.
88+
*
89+
* @param int $id
90+
* @return \Illuminate\Http\Response
91+
*/
92+
public function destroy($id)
93+
{
94+
//
95+
}
96+
}

app/Http/Controllers/Controller.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Bus\DispatchesJobs;
6+
use Illuminate\Routing\Controller as BaseController;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
9+
10+
class Controller extends BaseController
11+
{
12+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13+
}

0 commit comments

Comments
 (0)