Using ORM as API endpoint in Laravel
P粉239089443
P粉239089443 2023-09-05 19:29:46
0
2
500
<p>I'm trying to find best practices for deep integration with external APIs. The service I'm currently creating can call APIs, but when receiving data from these APIs, I find myself having to validate and sanitize the data. </p> <p>I know it's not possible to use Eloquent as an ORM for API data, but do we have a solution or practice to ensure that the data received from the API is validated and sanitized? </p> <p>I'm using the Shopify API and I'm integrating multiple endpoints. It would be much easier to use if I had a framework or ORM that ensured all data received was formatted. </p>
P粉239089443
P粉239089443

reply all(2)
P粉178894235

You can even validate the data externally or via the Illuminate\Support\Facades\Validator facade like this:

Validator::validate($data, $rules);
P粉253518620

To use third-party APIs in Laravel, it is recommended to use Laravel Data . Laravel Data is a package that provides a simple and intuitive way to interact with various data sources, including APIs.

Using Laravel Data, you can easily define models that represent the data returned by your API. These models can then be used to interact with the API, making requests and handling responses in a familiar and consistent way.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template