In Laravel 5.8 app using tymon/jwt-auth 1.0.0 I make backend rest api and I want to move all admin's controls directory, so I created Controller with command
php artisan make:controller API/Admin/SkillController --resource
which has :
<?php
namespace App\Http\Controllers\API\Admin;
use Auth;
use DB;
use Validator;
use App\User;
use App\library\CheckValueType;
use App\Settings;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Skill;
use App\Http\Resources\Admin\Skill as SkillResource;
use App\Http\Traits\funcsTrait;
class SkillController extends Controller
{
use funcsTrait;
private $requestData;
public function __construct()
{
$this->middleware('jwt.auth', ['except' => []]);
$request = request();
$this->requestData = $request->all();
}
...
In routes/api.php :
Route::group(['middleware' => 'jwt.auth', 'prefix' => 'admin', 'as' => 'admin.'], function ($router) {
Route::get('skills', 'API\Admin\SkillController@index');
...
}); // Route::group(['middleware' => 'jwt.auth', 'prefix' => 'admin', 'as' => 'admin.'], function ($router) {
Route::group(['middleware' => 'jwt.auth', 'prefix' => 'manager', 'as' => 'manager.'], function ($router) {
Route::get('users_assigned_to_task/{task_id}', 'API\ManagerController@users_assigned_to_task');
...
Also I have very similar app/Http/Controllers/API/ManagerController.php file( with routes defined above ) :
<?php
namespace App\Http\Controllers\API;
use Auth;
use DB;
use Validator;
use App\ActivityLog;
//use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use App\Task;
use App\UserSkill;
use App\UsersGroups;
use App\Event;
use App\EventUser;
use App\TaskAssignedToUser;
use App\Http\Traits\funcsTrait;
class ManagerController extends Controller
{
use funcsTrait;
private $requestData;
,
public function __construct()
{
$this->middleware('jwt.auth', ['except' => []]);
$request = request();
$this->requestData = $request->all();
}
...
which works ok for me.
The only difference is that SkillController is under “/admin/” subdirectory, but I set it with namespace...
But setting all parameters in axios GET request I see 401 error : https://imgur.com/a/xFgRK17
What is wrong ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire