-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from Kovah/dev
v0.0.39
- Loading branch information
Showing
103 changed files
with
11,084 additions
and
8,560 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
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
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,32 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Link; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
|
||
class LinkCheckController extends Controller | ||
{ | ||
/** | ||
* Search for a link based on a given url. | ||
* | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function __invoke(Request $request): JsonResponse | ||
{ | ||
$searchedUrl = $request->input('url', false); | ||
|
||
if (!$searchedUrl) { | ||
return response()->json(['linksFound' => false]); | ||
} | ||
|
||
$linkCount = Link::byUser($request->user()->id) | ||
->where('url', trim($searchedUrl)) | ||
->count(); | ||
|
||
return response()->json(['linksFound' => $linkCount > 0]); | ||
} | ||
} |
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,96 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\Models\LinkDeleteRequest; | ||
use App\Http\Requests\Models\LinkStoreRequest; | ||
use App\Http\Requests\Models\LinkUpdateRequest; | ||
use App\Models\Link; | ||
use App\Repositories\LinkRepository; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
|
||
class LinkController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function index(Request $request): JsonResponse | ||
{ | ||
$links = Link::byUser(auth()->id()) | ||
->orderBy( | ||
$request->input('order_by', 'created_at'), | ||
$request->input('order_dir', 'DESC') | ||
) | ||
->paginate(getPaginationLimit()); | ||
|
||
return response()->json($links); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param LinkStoreRequest $request | ||
* @return JsonResponse | ||
*/ | ||
public function store(LinkStoreRequest $request): JsonResponse | ||
{ | ||
$link = LinkRepository::create($request->all()); | ||
|
||
return response()->json($link); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function show($id): JsonResponse | ||
{ | ||
$link = Link::with(['lists', 'tags'])->findOrFail($id); | ||
|
||
return response()->json($link); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param LinkUpdateRequest $request | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function update(LinkUpdateRequest $request, $id): JsonResponse | ||
{ | ||
$link = Link::findOrFail($id); | ||
|
||
$updatedLink = LinkRepository::update($link, $request->all()); | ||
|
||
return response()->json($updatedLink); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param LinkDeleteRequest $request | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function destroy(LinkDeleteRequest $request, $id): JsonResponse | ||
{ | ||
$link = Link::findOrFail($id); | ||
|
||
$deletionSuccessfull = LinkRepository::delete($link); | ||
|
||
if ($deletionSuccessfull) { | ||
return response()->json(null, Response::HTTP_OK); | ||
} | ||
|
||
return response()->json(null, Response::HTTP_INTERNAL_SERVER_ERROR); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Link; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class LinkNotesController extends Controller | ||
{ | ||
/** | ||
* Get the notes for a specific link. | ||
* | ||
* @param $linkID | ||
* @return JsonResponse | ||
*/ | ||
public function __invoke($linkID): JsonResponse | ||
{ | ||
$link = Link::findOrFail($linkID); | ||
|
||
$notes = $link->notes()->paginate(getPaginationLimit()); | ||
|
||
return response()->json($notes); | ||
} | ||
} |
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\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\Models\ListDeleteRequest; | ||
use App\Http\Requests\Models\ListStoreRequest; | ||
use App\Http\Requests\Models\ListUpdateRequest; | ||
use App\Models\LinkList; | ||
use App\Repositories\ListRepository; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
|
||
class ListController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function index(Request $request): JsonResponse | ||
{ | ||
$lists = LinkList::byUser(auth()->id()) | ||
->orderBy( | ||
$request->input('order_by', 'created_at'), | ||
$request->input('order_dir', 'DESC') | ||
) | ||
->paginate(getPaginationLimit()); | ||
|
||
return response()->json($lists); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param ListStoreRequest $request | ||
* @return JsonResponse | ||
*/ | ||
public function store(ListStoreRequest $request): JsonResponse | ||
{ | ||
$link = ListRepository::create($request->all()); | ||
|
||
return response()->json($link); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function show($id): JsonResponse | ||
{ | ||
$list = LinkList::findOrFail($id); | ||
|
||
$list->links = route('api.lists.links', [$id], true); | ||
|
||
return response()->json($list); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param ListUpdateRequest $request | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function update(ListUpdateRequest $request, $id): JsonResponse | ||
{ | ||
$list = LinkList::findOrFail($id); | ||
|
||
$updatedList = ListRepository::update($list, $request->all()); | ||
|
||
return response()->json($updatedList); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param ListDeleteRequest $request | ||
* @param int $id | ||
* @return JsonResponse | ||
*/ | ||
public function destroy(ListDeleteRequest $request, $id): JsonResponse | ||
{ | ||
$list = LinkList::findOrFail($id); | ||
|
||
$deletionSuccessfull = ListRepository::delete($list); | ||
|
||
if ($deletionSuccessfull) { | ||
return response()->json(null, Response::HTTP_OK); | ||
} | ||
|
||
return response()->json(null, Response::HTTP_INTERNAL_SERVER_ERROR); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\LinkList; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class ListLinksController extends Controller | ||
{ | ||
/** | ||
* Get the links for a specific list. | ||
* | ||
* @param $listID | ||
* @return JsonResponse | ||
*/ | ||
public function __invoke($listID): JsonResponse | ||
{ | ||
$list = LinkList::findOrFail($listID); | ||
|
||
$links = $list->links()->paginate(getPaginationLimit()); | ||
|
||
return response()->json($links); | ||
} | ||
} |
Oops, something went wrong.