Init
This commit is contained in:
43
app/Http/Controllers/Api/UserApiController.php
Normal file
43
app/Http/Controllers/Api/UserApiController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\CacheHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Conner\Tagging\Model\Tag;
|
||||
|
||||
class UserApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get Tags (API).
|
||||
*/
|
||||
public function getBlacklist(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$tagWhiteList = [];
|
||||
$tagBlackList = [];
|
||||
|
||||
// All Tags
|
||||
foreach (CacheHelper::getAllTags() as $tag) {
|
||||
$tagWhiteList[] = $tag->name;
|
||||
}
|
||||
|
||||
// User Tags
|
||||
if ($user->tag_blacklist) {
|
||||
foreach ($user->tag_blacklist as $tag) {
|
||||
$t = Tag::where('slug', $tag)->first();
|
||||
$tagBlackList[] = $t->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'message' => 'success',
|
||||
'tags' => $tagWhiteList,
|
||||
'usertags' => $tagBlackList
|
||||
], 200);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user