I am trying to get the query string params. I have tried everything I can find on SO as well as general Google searches such as follows.
URL = http://example.com?companyId=1&subcompany=3;
Then in my controller:
$companyId = $request->query('companyId');
$subcompany = $request->query('subcompany);
So, if I go to mysite.com/api/getcompany?companyId=1&subcompany=3, I see exactly what I expect. I even get back the results that I expect to get. The problem is that then when this passes back to Vue, it is not at all what I expect. Instead, I get a list of all companies that are in the database with a null value for companyId and null value for subcompany. In looking at Telescope, the query that is actually processed is
select * from `prods` where
(
`companyId` = '..'
and `subCompany` = ''
)
and `products`.`deleted_at` is null
Yet, in my controller method this is what I am passing in
$products = Prod::where([
['companyId', '=', $companyId ],
['subcompany','=', $brandId]
])
->get();
In my Vue component, this is how I am making the call,
axios.get("api/getProds").then(res=>{
console.log(res.data);
});
So, not actually passing in the companyId as I don't have it available in the JS. Instead, I need to extract it from the query string. I am obviously missing something but I can't figure out what it is. Can someone see what is wrong with my code?