Skip to content

Commit

Permalink
Merge pull request #215 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Dec 22, 2022
2 parents 382932b + 223b3c6 commit a452e20
Show file tree
Hide file tree
Showing 20 changed files with 369 additions and 281 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/API/v1/GamejoltAccountBanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public function show(Request $request, $id)
/**
* Remove the specified resource.
*
* @urlParam id string required The UUID of the _ban_ you would like to remove.
* @urlParam id string required The UUID of the _ban_ you would like to remove
*
* @response 202 {
* "success": 'Ban was removed!',
* }
Expand Down
62 changes: 62 additions & 0 deletions app/Http/Controllers/API/v1/PostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace App\Http\Controllers\API\v1;

use App\Http\Controllers\Controller;
use App\Models\Post;
use Illuminate\Http\Request;

/**
* @group Post
*
* APIs for posts.
*/
class PostController extends Controller
{
public function __construct()
{
$this->middleware(['permission:posts.create'])->only(['store']);
}

/**
* Store a newly created resource in storage.
*
* @bodyParam title string required The title of the post. Example: Hello World
* @bodyParam body string required The content of the post. Example: This is a post.
* @bodyParam active boolean required Whether the post is active or not. Example: true
* @bodyParam sticky boolean required Whether the post is sticky or not. Example: false
* @bodyParam user_id int required The ID of the user. Example: 1
* @bodyParam published_at string optional The date the post was published. Example: 2021-01-01
*
* @response 201 {
* "title": "Test",
* "body": "Test",
* "active": True,
* "sticky": False,
* "user_id": 1,
* "published_at": "2021-12-21T20:59:14.000000Z",
* "created_at": "2021-12-21T20:59:14.000000Z",
* "updated_at": "2021-12-21T20:59:14.000000Z",
* "deleted_at": null,
* }
**/
public function store(Request $request)
{
if (! $request->user()->tokenCan('create')) {
return response()->json([
'error' => 'Token does not have access!',
]);
}
$request->validate([
'title' => 'required|string',
'body' => 'required|string',
'active' => 'required|boolean',
'sticky' => 'required|boolean',
'published_at' => 'required|date',
'user_id' => 'required|integer',
]);
$post = Post::create($request->all());

return response()->json($post, 201);
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Resource/ResourceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function render()
{
if (request()->is('resource/category/*')) {
$perPage = 15; // Default for pagination
$filtered = Resource::orderBy('created_at', 'desc')->filter(function ($resource) {
$filtered = Resource::orderBy('created_at', 'desc')->get()->filter(function ($resource) {
return $resource->hasCategory(Category::where('slug', request()->segment(3))->first());
});
$resources = new LengthAwarePaginator(
Expand Down
Loading

0 comments on commit a452e20

Please sign in to comment.