2021-07-31

Laravel Search by 3 values get nothing

I have a bunch of columns in a table what I need is to filter the table using few parameters using laravel Eloquent ORM.

For example companyName, StartDate. what I have tried is below

$objFetch = OpenOrder::where('companyName', $request->majorCompanies)
    ->orwhereBetween(
        'StartDate',
        array($request->startDate_start, $request->startDate_end)
    )
    ->orderby('id', 'desc')->get();

return response()->json([
    'success' => true,
    'objects' => $objFetch
]);


  "objects": [
                {
                   "company": "aa",
                   "StartDate": 2/24/2021,
                },
                {
                   "company": "aa"
                   "StartDate": 2/25/2021,
                },
                {
                   "company": "aa",
                   "StartDate": 4/15/2021,
                },
                {
                   "company": "bb",
                   "StartDate": 4/18/2021,
                },
                {
                   "company": "bb",
                   "StartDate": 2/24/2021,
                },
    
            ]

the answer should output the information given by the user for example: if the user select company aa and date between 2/24/2021,2/30/2021 output should be

"objects": [
                {
                   "company": "aa",
                   "StartDate": 2/24/2021,
                },
                {
                   "company": "aa"
                   "StartDate": 2/25/2021,
                },
                {
                   "company": "bb",
                   "StartDate": 2/24/2021,
                },
    
            ]

write your answers to solve this issue



from Recent Questions - Stack Overflow https://ift.tt/3lc6mh5
https://ift.tt/eA8V8J

No comments:

Post a Comment