Back

Question about authenticated laravel


Carlos posted 3 months ago

Hi guy,

I create my project to select users for the table user. The crud is okay.

Now I'm trying to make the security with my api, I installed the passport and testes with postman and it is okay too.

Now how I can call my route with the token authorization?

in web.pho I have:

Route::group(['prefix' => 'api', 'middleware' => 'auth:api'], function() { Route::group(['prefix' => 'user'], function () {

		Route::get('', ['uses' => '[email protected]']);

 });

});

In UserController.php I have.

class UserController extends BaseController { protected $user = null; public function __construct(Cliente $user) {

	$this->user = $user;
}
public function allUsers(Request $request)
{
	return $this->user->allUsers();

}

}

In cliente.php i have:

class Cliente extends Model { protected $hidden =['password'];

protected $fillable = ['first_name','last_name','email','password','city','state']; 

public function allUsers()
{
    //metodo do Eloquent para retornar todos os usuários
    return self::all();
}

}

Regards


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us