### Install Lodata using Composer Source: https://github.com/flat3/lodata/blob/5.x/doc/getting-started/README.md Installs the Lodata package into your Laravel application using Composer. After installation, restart your application to make the OData API endpoint available. ```sh composer require flat3/lodata ``` -------------------------------- ### OData Query Example Source: https://github.com/flat3/lodata/blob/5.x/doc/getting-started/README.md Demonstrates an OData query to retrieve specific user data. This example filters users by email domain, limits results, sorts by creation date, and selects specific properties. ```url http://127.0.0.1:8000/odata/Users?filter=endswith(email, '@gmail.com')&top=3&orderby=created_at desc&select=name,email,created_at ``` -------------------------------- ### OData Flight API Response Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchMultipartTest__test_query_param__1.txt Demonstrates a successful HTTP GET response from an OData service for flight data. It includes flight details, pagination links, and minimal metadata. ```APIDOC GET /odata/flights HTTP/1.1 Host: localhost Accept: application/json;metadata=minimal HTTP/1.0 200 OK content-type: application/json;metadata=minimal { "@context": "http://localhost/odata/$metadata#flights", "value": [ { "id": 1, "origin": "lhr", "destination": "lax", "gate": null, "duration": "PT11H25M0S" } ], "@nextLink": "http://localhost/odata/flights?top=1&skip=1" } ``` -------------------------------- ### lodata Expression Syntax Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_44__1.txt Demonstrates the syntax for expressions within the lodata project, specifically focusing on date/time comparisons. This example shows an input expression and its corresponding processed result. ```lodata-expression expression: origin eq PT36H result: ( origin eq P1DT12H0S ) ``` -------------------------------- ### Expression Evaluation Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_9__1.txt Demonstrates a simple expression evaluation where an input string is processed and returned. This example shows the input expression and its corresponding output result. ```text expression: "t1""" result: "t1""" ``` -------------------------------- ### Simple Expression Evaluation Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/ComputeTest__test_02__6.txt This snippet illustrates a basic expression evaluation. It takes an input expression and shows the corresponding output after processing. ```example expression: 1 add 2 result: ( 1 add 2 ) ``` -------------------------------- ### Vue DevExtreme DataGrid with OData 4.0 Source: https://github.com/flat3/lodata/blob/5.x/doc/clients/devextreme.md This Vue.js example demonstrates configuring the DevExtreme DxDataGrid to load data from an OData 4.0 endpoint. It shows how to set up the `odata/store` with the correct URL and includes a `beforeSend` function to add the required 'OData-Version: 4.0' header. ```vue ``` -------------------------------- ### lodata Expression and Result Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_58__1.txt This snippet demonstrates the syntax for expressions within the lodata project. It shows an example expression involving a comparison and a string function, along with its evaluated result. ```lodata-expression expression: 4 lt startswith(origin,'Veniam et') ``` ```lodata-expression result: ( 4 lt startswith( origin, 'Veniam et' ) ) ``` -------------------------------- ### JSON Data Record Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/EntitySetCreate/SQLTest__test_create_return_minimal__2.txt This snippet shows an example of a data record structure, likely used for storing information about entities within the system. It includes fields for identification, personal details, and status flags. ```json { "id": 6, "flight_id": null, "name": "lhr", "dob": null, "age": 4, "chips": null, "dq": null, "in_role": null, "open_time": null, "colour": null, "sock_colours": null, "emails": null } ``` -------------------------------- ### JSON Data Record Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/EntitySetCreate/EloquentTest__test_create_return_minimal__2.txt This snippet shows an example of a data record structure, likely used for storing information about entities within the system. It includes fields for identification, personal details, and status flags. ```json { "id": 6, "flight_id": null, "name": "lhr", "dob": null, "age": 4, "chips": null, "dq": null, "in_role": null, "open_time": null, "colour": null, "sock_colours": null, "emails": null } ``` -------------------------------- ### lodata Time Expression Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_4e__1.txt Demonstrates a lodata expression for filtering by time, showing the input expression and its processed result. This example highlights the syntax for time comparisons. ```lodata-expression expression: time(origin) eq 10:00:00 ``` ```lodata-expression result: ( time( origin ) eq 10:00:00 ) ``` -------------------------------- ### lodata Expression Syntax Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_4d__1.txt This snippet shows an example expression used within the lodata system. It demonstrates the syntax for filtering or querying data based on specific conditions, using functions and comparison operators. ```lodata-expression second(origin) eq 44 ``` -------------------------------- ### GET Flight by ID Response Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchMultipartTest__test_batch__1.txt Example of a successful HTTP GET request response for a single flight entity. It includes the flight details in JSON format, conforming to OData metadata. ```APIDOC GET /flights/{id} Response (200 OK): Content-Type: application/json;metadata=minimal ETag: W/"a714e2db58e276ecdcfcd98c25a0085a1465f571f780135a3ef2e976ec3a0afe" { "@context": "http://localhost/odata/$metadata#flights/$entity", "id": 1, "origin": "lhr", "destination": "lax", "gate": null, "duration": "PT11H25M0S" } Parameters: - id: Identifier for the flight. Return Value: - A JSON object representing the flight entity with properties like id, origin, destination, gate, and duration. ``` -------------------------------- ### Discover Eloquent Models Source: https://github.com/flat3/lodata/blob/5.x/doc/getting-started/README.md Exposes data from an Eloquent model via the OData API by adding a discovery call to the `boot()` method of your `AppServiceProvider`. Lodata automatically introspects the schema and detects field types. ```php \Lodata::discover(\App\Models\User::class) ``` -------------------------------- ### GET Airports List Response Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchMultipartTest__test_batch__1.txt Example of a successful HTTP GET request response for a collection of airport entities. It returns a 200 OK status with a JSON array containing multiple airport objects. ```APIDOC GET /airports Response (200 OK): Content-Type: application/json;metadata=minimal { "@context": "http://localhost/odata/$metadata#airports", "value": [ { "id": 1, "name": "Heathrow", "code": "lhr", "construction_date": "1946-03-25", "open_time": "09:00:00.000000", "sam_datetime": "2001-11-10T14:00:00+00:00", "review_score": null, "is_big": true, "country_id": 1 }, { "id": 2, "name": "Los Angeles", "code": "lax", "construction_date": "1930-01-01", "open_time": "08:00:00.000000", "sam_datetime": "2000-11-10T14:00:00+00:00", "review_score": null, "is_big": false, "country_id": 2 } // ... more airport objects ] } Return Value: - A JSON object containing a 'value' array, where each element is an airport entity with properties like id, name, code, dates, and country_id. ``` -------------------------------- ### Build and Parameterize Query Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_e__2.txt Illustrates the process of creating a logical query expression and its corresponding parameterized output, along with the values for the parameters. This is useful for dynamic query generation in applications. ```query-dsl Expression: id lt 4 or id lt 3 or id lt 2 Result: ( ( ( "flights"."id" < ? ) OR ( "flights"."id" < ? ) ) OR ( "flights"."id" < ? ) ) Parameters: 4,3,2 ``` -------------------------------- ### Build and Parameterize Query Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_e__5.txt Illustrates the process of creating a logical query expression and its corresponding parameterized output, along with the values for the parameters. This is useful for dynamic query generation in applications. ```query-dsl Expression: id lt 4 or id lt 3 or id lt 2 Result: ( ( ( "flights"."id" < ? ) OR ( "flights"."id" < ? ) ) OR ( "flights"."id" < ? ) ) Parameters: 4,3,2 ``` -------------------------------- ### HTTP: Request Namespaced Function Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md Example HTTP GET request to invoke a namespaced OData function (`com.example.math.add`). ```http http://localhost:8000/odata/com.example.math.add(a=1,b=2) ``` -------------------------------- ### Build and Parameterize Query Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_e__3.txt Illustrates the process of creating a logical query expression and its corresponding parameterized output, along with the values for the parameters. This is useful for dynamic query generation in applications. ```query-dsl Expression: id lt 4 or id lt 3 or id lt 2 Result: ( ( ( "flights"."id" < ? ) OR ( "flights"."id" < ? ) ) OR ( "flights"."id" < ? ) ) Parameters: 4,3,2 ``` -------------------------------- ### Request to Add Function Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md An example HTTP GET request to invoke the 'add' Lodata function with integer arguments 'a' and 'b'. ```http http://localhost:8000/odata/add(a=3,b=4) ``` -------------------------------- ### Build and Parameterize Query Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_e__4.txt Illustrates the process of creating a logical query expression and its corresponding parameterized output, along with the values for the parameters. This is useful for dynamic query generation in applications. ```query-dsl Expression: id lt 4 or id lt 3 or id lt 2 Result: ( ( ( "flights"."id" < ? ) OR ( "flights"."id" < ? ) ) OR ( "flights"."id" < ? ) ) Parameters: 4,3,2 ``` -------------------------------- ### Convert lodata Expression to SQL Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_59__4.txt This example shows a lodata expression that checks if the 'origin' field ends with 'Veniam et' and starts with 'Veniam et'. It is translated into a standard SQL query using LIKE operators and parameterized placeholders, along with the corresponding parameters. ```lodata expression: endswith(origin,'Veniam et') eq true and startswith(origin,'Veniam et') eq true result: ( ( "flights"."origin" LIKE ? ) AND ( "flights"."origin" LIKE ? ) ) parameters: %Veniam et,Veniam et% ``` -------------------------------- ### Convert lodata Expression to SQL Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_59__5.txt This example shows a lodata expression that checks if the 'origin' field ends with 'Veniam et' and starts with 'Veniam et'. It is translated into a standard SQL query using LIKE operators and parameterized placeholders, along with the corresponding parameters. ```lodata expression: endswith(origin,'Veniam et') eq true and startswith(origin,'Veniam et') eq true result: ( ( "flights"."origin" LIKE ? ) AND ( "flights"."origin" LIKE ? ) ) parameters: %Veniam et,Veniam et% ``` -------------------------------- ### Convert lodata Expression to SQL Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_59__3.txt This example shows a lodata expression that checks if the 'origin' field ends with 'Veniam et' and starts with 'Veniam et'. It is translated into a standard SQL query using LIKE operators and parameterized placeholders, along with the corresponding parameters. ```lodata expression: endswith(origin,'Veniam et') eq true and startswith(origin,'Veniam et') eq true result: ( ( "flights"."origin" LIKE ? ) AND ( "flights"."origin" LIKE ? ) ) parameters: %Veniam et,Veniam et% ``` -------------------------------- ### Convert lodata Expression to SQL Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_59__2.txt This example shows a lodata expression that checks if the 'origin' field ends with 'Veniam et' and starts with 'Veniam et'. It is translated into a standard SQL query using LIKE operators and parameterized placeholders, along with the corresponding parameters. ```lodata expression: endswith(origin,'Veniam et') eq true and startswith(origin,'Veniam et') eq true result: ( ( "flights"."origin" LIKE ? ) AND ( "flights"."origin" LIKE ? ) ) parameters: %Veniam et,Veniam et% ``` -------------------------------- ### Setup OData Entity Types, Sets, and Navigation Properties Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/relationships.md Demonstrates the foundational steps to configure OData relationships. This includes defining entity types with keys and declared properties, creating entity sets, establishing navigation properties to link entities, and setting up navigation bindings to connect the source entity set to the target entity set. It requires the Lodata library and its related classes. ```php class LodataServiceProvider extends ServiceProvider { public function boot() { /* Step 1 - Create the standard types and sets */ // Create the source entity type $person = new EntityType('person') ->setKey(new DeclaredProperty('id', Type::int32())) // Primary key ->addDeclaredProperty('name', Type::string()); // Create the related entity type $pet = new EntityType('pet') ->setKey(new DeclaredProperty('id', Type::int32())) // Primary key ->addDeclaredProperty('name', Type::string()) ->addDeclaredProperty('owner_id', Type::int32()); // Foreign key // Add the entity types to the model Lodata::add($person); Lodata::add($pet); // Create the entity sets $pets = new SQLEntitySet('pets', $pet); $people = new SQLEntitySet('people', $person); // Add the entity sets to the model Lodata::add($people); Lodata::add($pets); /* Step 2: Create the navigation property on the source type */ // Create the navigation property $toPet = new NavigationProperty( 'pets', // Navigation property name $pet // Target entity type ); $toPet->setCollection(true); // Navigates to a collection of entities // Add the navigation property to the source entity type $person->addProperty($toPet); /* Step 3: Create a binding between the two entity sets */ // Create a binding between the navigation property and its target entity set $binding = new NavigationBinding( $toPet, // Navigation property $pets // Target entity set ); // Attach the binding to the source entity set $people->addNavigationBinding($binding); } } ``` -------------------------------- ### HTTP: Request Random Person Entity Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md Example HTTP GET request to retrieve a random person entity from the OData service. ```http http://127.0.0.1:8000/odata/randomperson() ``` -------------------------------- ### Publish Lodata Configuration Source: https://github.com/flat3/lodata/blob/5.x/doc/getting-started/configuration.md Publishes Lodata's configuration files to your application using the Artisan command-line tool. This makes the configuration files available for modification. ```sh php artisan vendor:publish \ --provider="Flat3\Lodata\ServiceProvider" \ --tag="config" ``` -------------------------------- ### HTTP: Request Class Instance Operation Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md Example HTTP GET request to invoke an operation (`incr`) provided by a stateful class instance. ```http http://localhost:8000/odata/incr() ``` -------------------------------- ### Request to Add Function with Nullable Argument Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md An example HTTP GET request to invoke the 'add' Lodata function where one of the nullable arguments is omitted. ```http http://localhost:8000/odata/add(a=3) ``` -------------------------------- ### lodata Expression and Result Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_2c__1.txt Demonstrates the syntax for lodata expressions, including function calls like 'toupper' and comparison operators like 'eq'. It also shows the evaluated output of such an expression. ```lodata-expression expression: toupper(origin) eq 'abc123' ``` ```lodata-expression result: ( toupper( origin ) eq 'abc123' ) ``` -------------------------------- ### Request to Add Function with DateTimeOffset and Duration Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/operations.md An example HTTP GET request to call the 'add' Lodata function, passing a DateTimeOffset and a Duration as parameters. ```http http://localhost:8000/odata/add(timestamp=2004-01-01T12:00:00+00:00,increment=P12D) ``` -------------------------------- ### OData Request and Response for Collection Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/types/collections.md Provides an example of an HTTP GET request to retrieve a collection entity from a Lodata service, followed by the expected JSON response containing the collection data. ```URI GET http://localhost:8000/odata/Person ``` ```JSON { "@context": "http://localhost/odata/$metadata#person", "emails": [ "test@example.com", "test@gmail.com" ] } ``` -------------------------------- ### Get OData Endpoint Source: https://github.com/flat3/lodata/blob/5.x/doc/clients/dataverse.md Retrieves the OData endpoint for Microsoft Dataverse integration. This endpoint is required for connecting services like Power Apps to your Dataverse data. ```PHP \Lodata::getEndpoint() ``` -------------------------------- ### Add Filesystem Entity Set to Lodata Source: https://github.com/flat3/lodata/blob/5.x/doc/modelling/drivers/filesystem.md This snippet demonstrates how to register a `FilesystemEntitySet` with Lodata, specifying the entity set name and the filesystem disk to use. It shows the basic setup required to expose filesystem contents via Lodata. ```php class LodataServiceProvider extends ServiceProvider { public function boot() { $entitySet = new \Flat3\Lodata\Drivers\FilesystemEntitySet('files', new \Flat3\Lodata\Drivers\FilesystemEntityType()); $entitySet->setDisk('default'); \Lodata::add($entitySet); } } ``` -------------------------------- ### lodata Expression Parsing Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_7__1.txt Demonstrates the parsing of a logical expression in lodata syntax. Shows the transformation from a human-readable expression to a processed result. ```lodata-syntax expression: ( t1 OR t2 ) AND t3 ``` ```lodata-syntax result: ( ( "t1" OR "t2" ) AND "t3" ) ``` -------------------------------- ### $count System Query Option Source: https://github.com/flat3/lodata/blob/5.x/doc/making-requests/querying-data.md The $count system query option requests a count of matching resources. It can be included with the resources in the response. The example shows how to get the total number of people in a collection. ```uri GET http://localhost:8000/odata/People?$count=true ``` ```json { "@context": "http://localhost:8000/odata/$metadata#People", "value": [ { "id": 1, "FirstName": "Scott", "LastName": "Bumble", "Email": "scott.bumble@gmail.com" }, { "id": 2, "FirstName": "Scott", "LastName": "Yammo", "Email": "scott.yammo@gmail.com" }, { "id": 3, "FirstName": "Michael", "LastName": "Scott", "Email": "michael.scott@hotmail.com" } ], "@count": 3 } ``` -------------------------------- ### lodata Expression Syntax Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_18__1.txt Demonstrates the structure of expressions within the lodata project, showing how arithmetic operations, comparisons, and logical operators are combined. ```lodata-dsl expression: (id add 3.14) in (1.59, 2.14) or (id gt -2.40 and id gt 4 add 5) result: ( ( id add 3.14 ) in ( 1.59, 2.14 ) or ( ( id gt -2.4 ) and ( id gt ( 4 add 5 ) ) ) ) ``` -------------------------------- ### OData Airport Resource Operations Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchMultipartTest__test_reference_returned_entity__1.txt This entry documents common operations on the OData '/airports' resource. It includes examples of successful responses for creating (POST/PUT) and retrieving (GET) airport entities, detailing HTTP status codes, headers, and JSON payload structures. ```APIDOC POST /odata/airports Description: Creates a new airport resource. Request Body: (JSON payload representing airport data, e.g., {"name": "Test1", "code": "xyz"}) Response: HTTP/1.0 201 Created Content-Type: application/json;metadata=minimal Location: http://localhost/odata/airports(5) ETag: W/"14a52bab287f4842560310a2d159a97fdf6a96194db6ce825144501023efead4" Body: { "@context": "http://localhost/odata/$metadata#airports/$entity", "id": 5, "name": "Test1", "code": "xyz", "construction_date": null, "open_time": null, "sam_datetime": null, "review_score": null, "is_big": null, "country_id": null } GET /odata/airports(5) Description: Retrieves a specific airport resource by its ID. Response: HTTP/1.0 200 OK Content-Type: application/json;metadata=minimal ETag: W/"695f1d2e0d32260fc760b9a145fd7255e1790a62eb803ddd62ac1fa9c022f135" Body: { "@context": "http://localhost/odata/$metadata#airports/$entity", "id": 5, "name": "Test2", "code": "abc", "construction_date": null, "open_time": null, "sam_datetime": null, "review_score": null, "is_big": null, "country_id": null } Note: The provided examples show distinct responses for creation and retrieval, illustrating typical data payloads and metadata. ``` -------------------------------- ### OData Expression Transformation Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/LambdaTest__test_5d__1.txt Demonstrates the transformation of an OData expression, showing how an input query string is parsed and potentially normalized or rewritten into a result format. ```odata-input expression: airports/all(d:d/name eq 'hello') ``` ```odata-output result: airports/all(d:( d/name eq 'hello' ) ) ``` -------------------------------- ### OData JSON Batch Request and Response Example Source: https://github.com/flat3/lodata/blob/5.x/doc/making-requests/batch.md Demonstrates the structure of a JSON batch request for OData services, including multiple operations (GET, POST, PATCH), and the corresponding batched response payload. This format allows for efficient execution of several operations in a single HTTP POST request. ```uri POST http://localhost:8000/odata/$batch { "requests": [ { "id": 0, "method": "get", "url": "\/odata\/flights(1)" }, { "id": 1, "method": "post", "url": "\/odata\/airports", "headers": { "content-type": "application\/json" }, "body": { "name": "One", "code": "one" } }, { "id": 2, "method": "patch", "headers": { "content-type": "application\/json", "if-match": "W\/\"73fa0e567cdc8392d1869d47b3f0886db629d38780a5f2010ce767900cde7266\"" }, "url": "\/odata\/airports(1)", "body": { "code": "xyz" } }, { "id": 3, "method": "get", "url": "\/odata\/airports" } ] } ``` ```json { "responses": [ { "id": 0, "status": 200, "headers": { "content-type": "application\/json", "etag": "W\/\"2ccaaf443e26494dff243377cb72fb508b6dfad077dd4216f294be3fc0e7d0b5\"" }, "body": { "@context": "http:\/\/localhost:8000\/odata\/$metadata#flights\/$entity", "id": 1, "origin": "lhr", "destination": "lax", "gate": null, "duration": "PT11H25M0S" } }, { "id": 1, "status": 201, "headers": { "content-type": "application\/json", "location": "http:\/\/localhost:8000\/odata\/airports(5)", "etag": "W\/\"7f1bc052a54d9aed031b61b33efcee8e26c23b55f10814770f991b58d17c90e5\"" }, "body": { "@context": "http:\/\/localhost:8000\/odata\/$metadata#airports\/$entity", "id": 5, "name": "One", "code": "one" } }, { "id": 2, "status": 200, "headers": { "content-type": "application\/json", "etag": "W\/\"f593e92b83b424d5c98f33196d1cfff09a070417c1f5f37ffdb2a1451dd8343d\"" }, "body": { "@context": "http:\/\/localhost:8000\/odata\/$metadata#airports\/$entity", "id": 1, "name": "Heathrow", "code": "xyz" } }, { "id": 3, "status": 200, "headers": { "content-type": "application\/json" }, "body": { "@context": "http:\/\/localhost:8000\/odata\/$metadata#airports", "value": [ { "id": 1, "name": "Heathrow", "code": "xyz" }, { "id": 2, "name": "Los Angeles", "code": "lax" }, { "id": 3, "name": "San Francisco", "code": "sfo" }, { "id": 4, "name": "O'Hare", "code": "ohr" }, { "id": 5, "name": "One", "code": "one" } ] } } ] } ``` -------------------------------- ### Lodata Expression: Endswith and Startswith Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_5c__1.txt Demonstrates the use of 'endswith' and 'startswith' functions within the Lodata expression language. This snippet shows how to combine these functions with logical operators like 'and' and 'not' to create complex filtering conditions. The example illustrates an expression that checks if an 'origin' field ends with a specific string while not starting with it. ```lodata-expression expression: endswith(origin,'Veniam et') eq true and not (startswith(origin,'Veniam et') eq true) result: ( ( endswith( origin, 'Veniam et' ) eq true ) and ( not ( startswith( origin, 'Veniam et' ) eq true ) ) ) ``` -------------------------------- ### Expression Evaluation Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_4__1.txt Demonstrates the evaluation of a logical expression using a specific syntax. The input expression is transformed into a standardized, parenthesized format. ```expression expression: t1 OR t2 NOT t3 AND t4 result: ( "t2" OR ( ( NOT "t3" ) AND "t4" ) ) ``` -------------------------------- ### Lodata Expression: Endswith and Startswith Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_5a__1.txt Demonstrates the use of 'endswith' and 'startswith' functions within the Lodata expression language. This snippet shows how to combine these functions with logical operators like 'and' and 'not' to create complex filtering conditions. The example illustrates an expression that checks if an 'origin' field ends with a specific string while not starting with it. ```lodata-expression expression: endswith(origin,'Veniam et') eq true and not (startswith(origin,'Veniam et') eq true) result: ( ( endswith( origin, 'Veniam et' ) eq true ) and ( not ( startswith( origin, 'Veniam et' ) eq true ) ) ) ``` -------------------------------- ### OData $top and $skip Queries Source: https://github.com/flat3/lodata/blob/5.x/doc/making-requests/querying-data.md Demonstrates the OData $top and $skip system query options for pagination. $top specifies the number of items to return, and $skip specifies the number of items to skip. ```uri GET http://localhost:8000/odata/People?$top=2 ``` ```json { "@context": "http://localhost:8000/odata/$metadata#People", "value": [ { "id": 1, "FirstName": "Scott", "LastName": "Bumble", "Email": "scott.bumble@gmail.com" }, { "id": 2, "FirstName": "Scott", "LastName": "Yammo", "Email": "scott.yammo@gmail.com" } ], "@nextLink": "http://localhost:8000/odata/People?top=2&skip=2" } ``` ```uri GET http://localhost:8000/odata/People?$skip=1 ``` ```json { "@context": "http://localhost:8000/odata/$metadata#People", "value": [ { "id": 2, "FirstName": "Scott", "LastName": "Yammo", "Email": "scott.yammo@gmail.com" }, { "id": 3, "FirstName": "Michael", "LastName": "Scott", "Email": "michael.scott@hotmail.com" } ] } ``` -------------------------------- ### Expression Evaluation Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_30__1.txt Demonstrates the evaluation of a simple expression using lodata syntax. Shows the input expression and its parsed/evaluated result. ```lodata-expression expression: origin eq 4 div 3 result: ( origin eq ( 4 div 3 ) ) ``` -------------------------------- ### lodata Filter Expression Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_41__1.txt Demonstrates a typical filter expression used within the lodata system. This example shows how to filter based on an origin value. ```lodata-expression expression: origin eq 04:11:12 result: ( origin eq 04:11:12 ) ``` -------------------------------- ### Logical Expression to Query Translation Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_8__5.txt Illustrates the process of defining a logical expression and its subsequent transformation into a query string with placeholders, along with the list of parameters required for execution. This format is useful for understanding how complex filtering logic is represented and parameterized. ```APIDOC Expression: (t1 OR (t2 AND t3)) Resulting Query: ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) OR ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) AND ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) ) ) Parameters: %t1% %t1% %t2% %t2% %t3% %t3% ``` -------------------------------- ### Airport JSON Data Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchJSONTest__test_prefer_minimal__3.txt This snippet shows an example of JSON data representing airport information. It includes modifications to existing records and the addition of new ones, illustrating common data update patterns. ```JSON [ { "id": 1, "name": "Heathrow", "code": "xyz", "construction_date": "1946-03-25", "sam_datetime": "2001-11-10T14:00:00.000000Z", "open_time": "09:00:00", "review_score": null, "is_big": true, "country_id": null }, { "id": 5, "name": "One", "code": "one", "construction_date": null, "sam_datetime": null, "open_time": null, "review_score": null, "is_big": null, "country_id": null } ] ``` -------------------------------- ### OData HTTP Response Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Protocol/BatchMultipartTest__test_action_invocation__1.txt Demonstrates a successful HTTP response from an OData service. It includes standard HTTP headers and a JSON payload conforming to OData metadata specifications. ```APIDOC HTTP/1.0 200 OK Content-Type: application/json;metadata=minimal {"@context":"http://localhost/odata/$metadata#Edm.Int32","value":7} ``` -------------------------------- ### Parse lodata Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_1f__1.txt Illustrates the transformation of a lodata expression string into its parsed, structured representation. This example shows a simple boolean logic operation. ```lodata-expression expression: origin eq 'b' or not (origin eq 'a') result: ( ( origin eq 'b' ) or ( not ( origin eq 'a' ) ) ) ``` -------------------------------- ### Logical Expression to Query Translation Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_8__2.txt Illustrates the process of defining a logical expression and its subsequent transformation into a query string with placeholders, along with the list of parameters required for execution. This format is useful for understanding how complex filtering logic is represented and parameterized. ```APIDOC Expression: (t1 OR (t2 AND t3)) Resulting Query: ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) OR ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) AND ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) ) ) Parameters: %t1% %t1% %t2% %t2% %t3% %t3% ``` -------------------------------- ### Logical Expression to Query Translation Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_8__3.txt Illustrates the process of defining a logical expression and its subsequent transformation into a query string with placeholders, along with the list of parameters required for execution. This format is useful for understanding how complex filtering logic is represented and parameterized. ```APIDOC Expression: (t1 OR (t2 AND t3)) Resulting Query: ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) OR ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) AND ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) ) ) Parameters: %t1% %t1% %t2% %t2% %t3% %t3% ``` -------------------------------- ### lodata Expression Evaluation Example Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_29__1.txt Demonstrates the syntax for evaluating expressions within the lodata system. This example shows a substring comparison used for filtering or data selection. ```lodata-expression expression: substring(origin,1,4) eq 'abc123' ``` ```lodata-expression result: ( substring( origin, 1, 4 ) eq 'abc123' ) ``` -------------------------------- ### Logical Expression to Query Translation Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/SearchTest__test_8__4.txt Illustrates the process of defining a logical expression and its subsequent transformation into a query string with placeholders, along with the list of parameters required for execution. This format is useful for understanding how complex filtering logic is represented and parameterized. ```APIDOC Expression: (t1 OR (t2 AND t3)) Resulting Query: ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) OR ( ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) AND ( "flights"."from" LIKE ? OR "flights"."to" LIKE ? ) ) ) Parameters: %t1% %t1% %t2% %t2% %t3% %t3% ``` -------------------------------- ### Filter by Date Expression Source: https://github.com/flat3/lodata/blob/5.x/tests/__snapshots__/Parser/FilterTest__test_3f__1.txt Demonstrates the syntax for filtering data using an expression. The example shows how to compare a date field 'origin' to a specific date using the 'eq' operator. ```lodata-query expression: origin eq 2000-01-01 result: ( origin eq 2000-01-01 ) ``` -------------------------------- ### Assert POST Request with Snapshot Source: https://github.com/flat3/lodata/blob/5.x/doc/introduction/reporting-issues.md Demonstrates creating a POST request with a JSON body and a specific path using the `Request` object. It then asserts the HTTP response code and generates a snapshot of the output, useful for testing API behavior. ```php $this->assertJsonResponse( (new Request) ->post() ->body([ 'name' => 'Harry Horse', ]) ->path('/Flights(1)/passengers'), Response::HTTP_CREATED ); ```