-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
418 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Resources\ForumResource; | ||
use App\Models\Forum; | ||
use Illuminate\Http\Request; | ||
|
||
class ForumController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$forId = $request->forid; | ||
$query = Forum::query()->orderBy("sort", "asc")->with("moderators"); | ||
if ($forId) { | ||
$query->where("forid", $forId); | ||
} | ||
$list = $query->get(); | ||
$resource = ForumResource::collection($list); | ||
return $this->success($resource); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Resources\OverForumResource; | ||
use App\Models\OverForum; | ||
use Illuminate\Http\Request; | ||
|
||
class OverForumController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function index() | ||
{ | ||
$list = OverForum::query()->orderBy("sort", "asc")->get(); | ||
$resource = OverForumResource::collection($list); | ||
return $this->success($resource); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Resources\ForumResource; | ||
use App\Http\Resources\TopicResource; | ||
use App\Models\Forum; | ||
use App\Models\Topic; | ||
use Illuminate\Http\Request; | ||
|
||
class TopicController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return array | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$forumId = $request->forum_id; | ||
$query = Topic::query() | ||
->orderBy("sticky", "desc") | ||
->with("user", "firstPost", "lastPost") | ||
; | ||
if ($forumId) { | ||
$query->where("forumid", $forumId); | ||
} | ||
$list = $query->get(); | ||
$resource = TopicResource::collection($list); | ||
return $this->success($resource); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, OverForum $overForum) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \App\Models\OverForum $overForum | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(OverForum $overForum) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class ForumResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
'description' => $this->description, | ||
'postcount' => $this->postcount, | ||
'topiccount' => $this->topiccount, | ||
'moderators' => UserResource::collection($this->whenLoaded("moderators")), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class OverForumResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
'description' => $this->description, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class PostResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'added' => format_datetime($this->added), | ||
'body' => $this->body, | ||
'user' => new UserResource($this->whenLoaded('user')), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class TopicResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'subject' => $this->subject, | ||
'locked' => $this->locked, | ||
'forumid' => $this->forumid, | ||
'sticky' => $this->sticky, | ||
'hlcolor' => $this->hlcolor, | ||
'views' => $this->views, | ||
'user' => new UserResource($this->whenLoaded('user')), | ||
'lastPost' => new PostResource($this->whenLoaded('lastPost')), | ||
'firstPost' => new PostResource($this->whenLoaded('firstPost')), | ||
]; | ||
} | ||
} |
Oops, something went wrong.