mirror of
https://repo.getmonero.org/AnonDev/xmrmemes.git
synced 2025-05-16 08:22:12 -04:00
Improve the API
- sort /api/memes newest first - add endpoints for lookup of user and meme by id - add endpoint for paginating through the given user's memes
This commit is contained in:
parent
012094bd65
commit
a09b7e9f02
2 changed files with 23 additions and 1 deletions
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Meme;
|
||||
use App\Models\User;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
|
||||
class ApiController extends Controller
|
||||
|
@ -20,7 +21,25 @@ class ApiController extends Controller
|
|||
|
||||
public function memes()
|
||||
{
|
||||
$memes = Meme::paginate(100);
|
||||
$memes = Meme::orderByDesc('created_at')->paginate(100);
|
||||
return $memes;
|
||||
}
|
||||
|
||||
public function memeById($id)
|
||||
{
|
||||
$meme = Meme::where('id', $id)->firstOrFail();
|
||||
return $meme;
|
||||
}
|
||||
|
||||
public function userById($id)
|
||||
{
|
||||
$user = User::where('id', $id)->firstOrFail();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function userByIdMemes($id)
|
||||
{
|
||||
$memes = Meme::where('user_id', $id)->orderByDesc('created_at')->paginate(20);
|
||||
return $memes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue