mostafalaravel
3 weeks ago

how to get only the minimum value ?

Posted 3 weeks ago by mostafalaravel

Hello ,

Bellow the result of : return taskStatus::find([3,5,6,7,1,2]);

"minimumStatus": [
        {
          "id": 3,
          "created_at": "2019-09-23 15:20:46",
          "updated_at": "2019-09-23 15:20:49",
          "name": "scheduled",
          "description": null,
          "order": 3,
          "invoiced": false,
          "operational_status": true
        },
        {
          "id": 5,
          "created_at": "2019-09-23 15:23:34",
          "updated_at": "2019-09-23 15:23:43",
          "name": "ready to invoice",
          "description": null,
          "order": 5,
          "invoiced": false,
          "operational_status": false
        },
        {
          "id": 6,
          "created_at": "2019-09-23 15:23:36",
          "updated_at": "2019-09-23 15:23:45",
          "name": "invoiced",
          "description": null,
          "order": 6,
          "invoiced": true,
          "operational_status": false
        },
        {
          "id": 7,
          "created_at": "2019-09-23 15:23:39",
          "updated_at": "2019-09-23 15:23:47",
          "name": "done",
          "description": null,
          "order": 7,
          "invoiced": true,
          "operational_status": false
        },
        {
          "id": 1,
          "created_at": "2019-09-23 13:29:54",
          "updated_at": "2019-09-23 13:29:56",
          "name": "ready",
          "description": null,
          "order": 1,
          "invoiced": false,
          "operational_status": true
        },
        {
          "id": 2,
          "created_at": "2019-09-23 13:31:43",
          "updated_at": "2019-09-23 13:31:40",
          "name": "ongoing",
          "description": null,
          "order": 2,
          "invoiced": false,
          "operational_status": true
        }
      ],

How to return only one result which is the minimum value of the attribute order and the supposed result is :

 "minimumStatus": [
        
{
          "id": 1,
          "created_at": "2019-09-23 13:29:54",
          "updated_at": "2019-09-23 13:29:56",
          "name": "ready",
          "description": null,
          "order": 1,
          "invoiced": false,
          "operational_status": true
        }
]

Thanks

Please sign in or create an account to participate in this conversation.