selahattinunlu / laravel-api-query-builder

Laravel & Lumen Api Query Builder Package
332 stars 66 forks source link

Improvements and compatibility with Laravel 5.5 #34

Open robsontenorio opened 6 years ago

robsontenorio commented 6 years ago

Some of this changes are based on another forks who was not submitted by authors.

LARAVEL 5.5

IMPROVEMENTS

For non existing ID, firstOrFail() throws ModelNotFoundException

       /v1/companies/999999?includes=status&.....

Model Company.php

    public static function get($id, array $params = [])
    {
        $params['id'] = $id;
        $request = RequestCreator::createWithParameters($params);        
        $company = new QueryBuilder(new Company, $request);

        return $company->build()->firstOrFail();
    }
walliby commented 6 years ago

@robsontenorio Nicely done. Looks like there are several of us who are finding this library valuable. @selahattinunlu Are you still maintaining this project? Another improvement I have found, is to turn the result type into a query param so you can pass paginate, list, or get to an endpoint. Not sure about creating a merge request here if its not maintained but here it is if @robsontenorio is interested: https://github.com/walliby/laravel-api-query-builder/commit/349dfb5ae8ea5553f23a04f3c95fdfa6d350c2cc

robsontenorio commented 6 years ago

@walliby that methods already exists:

walliby commented 6 years ago

Yes, I just added a query string param for them so you can use all three in the same endpoint

Get Outlook for Androidhttps://aka.ms/ghei36


From: robsontenorio notifications@github.com Sent: Monday, November 6, 2017 6:57:39 AM To: selahattinunlu/laravel-api-query-builder Cc: Joshua Wallace; Mention Subject: Re: [selahattinunlu/laravel-api-query-builder] Improvements and compatibility with Laravel 5.5 (#34)

@wallibyhttps://github.com/walliby that methods already exists:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/selahattinunlu/laravel-api-query-builder/pull/34#issuecomment-342127798, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFGf3VlQdCCToV7oPXzIJ8VruS-BuCxkks5szvQzgaJpZM4QJyqA.

robsontenorio commented 6 years ago

I understand. But in my case I m working with restfull endpoints , so my urls hits two diferents methods on Models:

walliby commented 6 years ago

I see, you always paginate your /users endpoint whereas we have a need to get all results without pagination sometimes.

Get Outlook for Androidhttps://aka.ms/ghei36

From: robsontenorio Sent: Monday, November 6, 7:42 AM Subject: Re: [selahattinunlu/laravel-api-query-builder] Improvements and compatibility with Laravel 5.5 (#34) To: selahattinunlu/laravel-api-query-builder Cc: Joshua Wallace, Mention

I understand. But in my case I m working with restfull endpoints , so my urls hits two diferents methods on Models: /users/99 => get() /users?includes=city => paginate() — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/selahattinunlu/laravel-api-query-builder/pull/34#issuecomment-342137263, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFGf3TwlDsF-Gi7ZYPi_ndR9tV6_XNvPks5szv6ggaJpZM4QJyqA.

robsontenorio commented 6 years ago

@walliby nice, just waiting for @selahattinunlu when he got enough time to merge it :)

zlanich commented 6 years ago

Hey @selahattinunlu, are you able to merge this soon? I'm needing to add additional query params into the Request using the RequestCreator and I'm getting the PATH_INFO error.

wgmv commented 6 years ago

Package is not maintained anymore. Anyone willing to take over? Also wating for these changes...

robsontenorio commented 6 years ago

@wgmv as you said "Package is not maintained anymore". An alternative can be https://github.com/spatie/laravel-query-builder . It seems work well.