Giter Club home page Giter Club logo

laravel-api-boilerplate's People

Contributors

jakubovitz avatar specialtactics avatar tom5om avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-api-boilerplate's Issues

Telescope Error

Installing the boilerplate from scratch it will give an error that can be solved updating the laravel/telescope version to 2.0 in composer

session id changes with every request

Hey, i have been building my api system on top of your boilerplate, which saved me a huge amount of time, but im having trouble after authentication, the AUTH works fine and i get the token in response, but in my API i have set a session variable and its active only for that request , in the consequent request the session is flushed out and i get a different token in response. i have enabled Sessions in API middleware, and and set the session domain.

the session seems to retain when i make the request through postman, but not when i use axios or guzzle. and i can see the session files created in storage folder with different token

array:2 [
  "_token" => "JpRUe19KiVojlXvnahHSgcsJmbI8Cj4zb9FP1kEE"
  "use_company" => 1
]

[
"_token" => "OzfWDpUykwt0OnASz627e7o3C7LtlYgONTs6qqiH"
]

[BUG]

Version Information
PHP Version: 7.3
Package Version (l5-api): 1.0

Describe the bug
Unable to use with laravel nova. Nova Login page just refresh when the correct credentials are supplied.

To Reproduce
Steps to reproduce the behavior:

  1. Install laravel nova
  2. Try to login to Nova

Expected behavior
Should be able to login with the correct credentials

Additional context
Looks like there is a conflict with between the nova route and dingo

display errors

how i should return error messages it has anything documented about that? like, i'm doing a function to return followers and in my UserController i return just:

{
 "error": "you can't follow yourself"
}

any pattern?

Class Specialtactics\L5Api\Http\Middleware\SnakeCaseInputParameterKeys does not exist

Cloned today, after running the commands in the page i still find this error.

taking a peak at \Specialtactics\L5Api\Http\Middleware\SnakeCase

/**
 * Class SnakeCaseInputParameterKeys
 *
 * This middleware makes sure all incoming request parameters are snake cased for the application
 */
class SnakeCase

so maybe this it's a typo on l5-api repo.

after renaming changing this:

--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -61,7 +61,7 @@ class Kernel extends HttpKernel
         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
-        'snake_case' => \Specialtactics\L5Api\Http\Middleware\SnakeCaseInputParameterKeys::class,
+        'snake_case' => \Specialtactics\L5Api\Http\Middleware\SnakeCase::class,
         'check_role' => \Specialtactics\L5Api\Http\Middleware\CheckUserRole::class,
     ];

it worked

what happens after generate the controller and model?

i generated the controllers and models using the artisan command recommended at docs, but I noticed that the UserController does not have an index, show, update and delete methods but they still works under the hood anyway, I looked at routes/api.php, and saw all methods in a different pattern like get, getAll, put, path and delete using HTTP terms, my question is, those methods are auto-generated automatically after generating the controller?

Error on patch

"message": "Call to a member function validateResourceUpdate() on null",
"statusCode": 500,
"debug": {
"line": 256,
"file": "/var/www/html/funi-api-vi/vendor/specialtactics/l5-api/src/Http/Controllers/RestfulController.php",
"class": "Error",

but the $request->input() and $model all has data

[BUG]

on creating a new user with the role return 500 Internal Server Error with
"message": "Return value of App\Entities\User::getStoredRole() must implement interface Spatie\Permission\Contracts\Role, null returned",
how to solve this issue

[BUG]

Version Information
PHP Version: 8.1
Package Version (l5-api):

Describe the bug
docker-compose up cause

ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.
ERROR: Service 'workspace' failed to build: The command '/bin/sh -c echo $(ruby -v) &&     gem update --system &&     gem install bundler &&     gem install apiaryio' returned a non-zero code: 1

To Reproduce
Steps to reproduce the behavior:

  1. download project
  2. docker-compose up in console

Routing access

I installed this project, but didn't my interface routing add an API after the address? Why can't you access it?

[F-REQ] SSL Support

I'm currently using this boilerplate to host an api, and linked to a domain name api.example.com.

I need to serve the domain through ssl but it seems the docker-compose file only supports port 80? Would I need to edit the nginx config files in order to make it run over HTTPS? my domain is under cloudflare

JWT

I'm writing here not because there is an issue, but just for know a thing that keeps me blocked.
I'm pretty new to JWT, and while building all the databases and understanding this beautiful boilerplate you created, I got stuck while trying to authenticate for get a token.
I created a User in a separated method, then I tried to login using Postman putting the Accept header and the Basic Auth with the credentials but always got the error "Token has expired".
I tried debugging the error for a couple of hours and still don't know where I'm wrong.
If you can help me I will be so grateful. Thanks

Unauthorized Login

Hello,

First of all, thanks for this great boilerplate, I think it's gonna help a lot in a short future, you did an amazin job!

But I'm struggling with the authentication system.

I've been using the collection and environment issued inside the /docs directory to manage my requests from Postman but I keep getting the following response when hitting the Auth/LoginasAdmin request:

"message": "Unauthorized login",
"statusCode": 401,

Any idea on what could be wrong here?
I'm using the JWT authentication system.

I've checked the database, it's been correctly seeded. The Postman variables are correct, the GET request doesn't return any syntax error.

If I hit the Auth/GetCurrentUser I get the following response:

"message": "Wrong number of segments",
"statusCode": 401,

Here is the complete log of the Admin login request:

{ "message": "Unauthorized login", "statusCode": 401, "debug": { "line": 33, "file": "/home/david/Sites/devtest/vendor/specialtactics/l5-api/src/Http/Controllers/Features/JWTAuthenticationTrait.php", "class": "Specialtactics\\L5Api\\Exceptions\\UnauthorizedHttpException", "trace": [ "#0 [internal function]: App\\Http\\Controllers\\Auth\\AuthController->token(Object(Dingo\\Api\\Http\\Request))", "#1 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)", "#2 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('token', Array)", "#3 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Auth\\AuthController), 'token')", "#4 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()", "#5 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\\Routing\\Route->run()", "#6 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#7 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#8 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#9 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#10 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(58): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#11 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), 60, '1')", "#12 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#13 /home/david/Sites/devtest/vendor/specialtactics/l5-api/src/Http/Middleware/SnakeCaseInputParameterKeys.php(51): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#14 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Specialtactics\\L5Api\\Http\\Middleware\\SnakeCaseInputParameterKeys->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#15 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#16 /home/david/Sites/devtest/vendor/dingo/api/src/Http/Middleware/PrepareController.php(45): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#17 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Dingo\\Api\\Http\\Middleware\\PrepareController->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#18 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#19 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#20 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))", "#21 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))", "#22 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute(Object(Dingo\\Api\\Http\\Request), Object(Illuminate\\Routing\\Route))", "#23 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))", "#24 /home/david/Sites/devtest/vendor/dingo/api/src/Routing/Adapter/Laravel.php(88): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))", "#25 /home/david/Sites/devtest/vendor/dingo/api/src/Routing/Router.php(514): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')", "#26 /home/david/Sites/devtest/vendor/dingo/api/src/Http/Middleware/Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))", "#27 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#28 /home/david/Sites/devtest/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#29 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#30 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#31 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#32 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#33 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#34 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#35 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#36 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#37 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#38 /home/david/Sites/devtest/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#39 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\\Cors\\HandlePreflight->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#40 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))", "#41 /home/david/Sites/devtest/vendor/dingo/api/src/Http/Middleware/Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))", "#42 /home/david/Sites/devtest/vendor/dingo/api/src/Http/Middleware/Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))", "#43 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))", "#44 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))", "#45 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))", "#46 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))", "#47 /home/david/Sites/devtest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))", "#48 /home/david/Sites/devtest/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))", "#49 /home/david/.config/composer/vendor/cpriego/valet-linux/server.php(204): require('/home/david/Sit...')", "#50 {main}" ] } }

WithPivot removed during transformation

I have a many to many relation with additional fields.

It works fine until I try to query a item or collection with additional fields.

Return the "pure" raw item the additional pivot fields are there.

Using return $this->response->item($company, $this->getTransformer()); the additional fields wont appear.

ID vs UUID

More a question than a bug, I am eyeing up your solution to migrate to from my current API setup.

I currently use a sequential ID for each entity and currently request a row using that and an organisation id.

i.e. tbl systems:

id INT auto inc PRIMARY
seq INT
organisation_id INT
name VARCHAR
......

I do this so the org has their own 1 based, scoped id's for each entity and I'm using this in the url like systems/1.

I notice this implementation uses UUID, could you let me know what your recommended approach is for my use case?

Got Error transform() must be an instance of Specialtactics\\L5Api\\Transformers\\Object, instance of stdClass given

Using version 241d8f1

ERROR

Argument 1 passed to Specialtactics\\L5Api\\Transformers\\RestfulTransformer::transform() must be an instance of Specialtactics\\L5Api\\Transformers\\Object, instance of stdClass given, called in /var/www/job/vendor/league/fractal/src/Scope.php on line 407

DEBUG INFO
File: /var/www/job-api-server/vendor/specialtactics/l5-api/src/Transformers/RestfulTransformer.php
Line: 23

Please advice.

Named routes not working using dingo api router

Hey,

im moving my current project into Api using this boiler plate, and i have noticed that my laravel named routes dont work when using the dingo APi router.

$api->get('/dashboard', 'PagesController@dashboard')->name('dashboard2');

then i get this error from the controller

Route [dashboard2] not defined.

is there a particular reason why this is happening?

thanks

Does not support php8.0๏ผŸ

composer create-project

Your requirements could not be resolved to an installable set of packages.

Problem 1
- specialtactics/l5-api[v3.0.0-beta1, ..., v3.0.1] require php ^7.3 -> your php version (8.0.3) does not satisfy that requirement.
- Root composer.json requires specialtactics/l5-api ^3.0 -> satisfiable by specialtactics/l5-api[v3.0.0-beta1, v3.0.0, v3.0.1].

[BUG]

Version Information
PHP Version:
Package Version (l5-api):

Describe the bug
I am getting an error when trying to setup docker.
configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To Reproduce
When I run docker-compose up
Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

route for login

where is the route for issue the token? i need build it myself? when i type php artisan route:list i don't see any route for token, just some GET and DELETE

[BUG] Class name must be a valid object or a string

Version Information
PHP Version: 7.4.5
Laravel Version: 7.11
Package Version (l5-api): ^2.0

Describe the bug
After installing and creating an example controller and model using command php artisan make:api-resource Book, I get an error when sending a request to API. Headers are setted on request.

Error

{
    "message": "Class name must be a valid object or a string",
    "statusCode": 500,
    "debug": {
        "line": 41,
        "file": "C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\specialtactics\\l5-api\\src\\Http\\Controllers\\RestfulController.php",
        "class": "Error",
        "trace": [
            "#0 [internal function]: Specialtactics\\L5Api\\Http\\Controllers\\RestfulController->getAll()",
            "#1 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)",
            "#2 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('getAll', Array)",
            "#3 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\BookController), 'getAll')",
            "#4 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(196): Illuminate\\Routing\\Route->runController()",
            "#5 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(685): Illuminate\\Routing\\Route->run()",
            "#6 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#7 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#8 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#9 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#10 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), 60, '1')",
            "#11 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\specialtactics\\l5-api\\src\\Http\\Middleware\\SnakeCaseInputParameterKeys.php(52): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#12 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Specialtactics\\L5Api\\Http\\Middleware\\SnakeCaseInputParameterKeys->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#13 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Http\\Middleware\\PrepareController.php(45): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#14 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Dingo\\Api\\Http\\Middleware\\PrepareController->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#15 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#16 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#17 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))",
            "#18 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Dingo\\Api\\Http\\Request), Object(Illuminate\\Routing\\Route))",
            "#19 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))",
            "#20 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Routing\\Adapter\\Laravel.php(88): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
            "#21 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Routing\\Router.php(518): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')",
            "#22 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
            "#23 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#24 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#25 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#26 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#27 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#28 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#29 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#30 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#31 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#32 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#33 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#34 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#35 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#36 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#37 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#38 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))",
            "#39 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#40 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
            "#41 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#42 C:\\xampp\\htdocs\\laravel-api-boilerplate\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
            "#43 C:\\xampp\\htdocs\\laravel-api-boilerplate\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
            "#44 {main}"
        ]
    }
}

Suggestion: Integrate Socialite auth into this package

@specialtactics this isn't an issue per se, but I want to bring your attention to a codebase I've forked and gotten working that (might?) be good to integrate into this one.

Some context: My primary stack is nuxt (vue framework) for the frontend, talking to laravel apis. Check out a working version of laravel socialite with Nuxt.js here: https://github.com/connecteev/laravel-nuxt-authentication

Nuxt is amazing but if you don't care about the nuxt part, just ignore everything in the 'client' folder, and everything else should still work like a regular laravel app. I've tested Google, Twitter, Linkedin and Github auth and added detailed notes to the readme to the point where it is more or less dummy-proof.

2 ideas here:

  1. what if we combined these into one repo so it became an end-to-end working example of
    specialtactics/laravel5-api-boilerplate with nuxt?
  2. After the user is logged in, we could add authenticated API tokens/requests from the nuxt client, basically preventing unauthorized use of the API after login. For example: after a user logs in, the nuxt client would request data over Axios/Ajax for a logged-in user than no one else should be able to access

Not sure if any of this resonates but thought I'd mention.

[BUG] Testing cannot read route URI by name

Version Information
PHP Version: 7.2.1
Package Version (l5-api): v1.2.1

Describe the bug

  • File tests/Api/UserControllerTest
  • Case: Unable to read route uri by named-route
  • sample code:
<?php

namespace Tests\Api;

use Tests\ApiTestCase;

class UserTest extends ApiTestCase
{
    public function doGetAll()
    {
        // $jsonResponse = $this->actingAsAdmin()->json('GET', '/api/users');
        $jsonResponse = $this->actingAsAdmin()->json('GET', route('api.users.index', [], false));
        
        // Check status and structure
        $jsonResponse
            ->assertStatus(200);
    }

}

To Reproduce
Steps to reproduce the behavior:

  1. Go to project path
  2. Run phpunit
  3. See error

Expected behavior
Named route URI can be read on phpunit testing mode.

Additional context
Add any other context about the problem here.

I can't access view from the web routes

I want to run a web application side by side with a mobile application. I have enabled the web route in the RouteServiceProvider.php but when I try to access a page via route, I get an error that InvalidArgumentException View [index] not found..

Please , how do I solve this?

problem with current test unit

with mysql it composer test gives an error
Error in bootstrap script: Illuminate\Database\QueryException:
SQLSTATE[08006] [7] received invalid response to SSL negotiation: Y (SQL: select tablename from pg_catalog.pg_tables where schemaname in ('public'))

[BUG] 'id' in response got unset if $primaryKey in Model set to 'id'

Version Information
PHP Version: 7.3
Package Version (l5-api): 1.0.3

Describe the bug
The Primary got unset in response.

To Reproduce
Steps to reproduce the behavior:
Set $primaryKey = 'id' in Model.
Return response using BaseTransformer.

Expected behavior
Data with primary key.

Additional context
nope

I managed to find out the bug in RestfulTransformer.php.

 /**
  * Primary Key transformation - all PKs to be called "id"
  */
 $transformed = array_merge(
        ['id' => $model->getKey()],
        $transformed
);
unset($transformed[$model->getKeyName()]);

I added if condition to check if the primary key equal to 'id' or not, before the unset action.

 /**
  * Primary Key transformation - all PKs to be called "id"
  */
 $transformed = array_merge(
        ['id' => $model->getKey()],
        $transformed
);
if ($model->getKeyName() != 'id') {
        unset($transformed[$model->getKeyName()]);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.