Contents:
Did you define customer table name in auth file?
And are you logged in?
Did the solution i gave worked?
Is it blank space?
There are no brackets?
Did you define customer table name in auth file?
And are you logged in?
Did the solution i gave worked?
Is it blank space?
There are no brackets?
Omar Malas 2022-08-07 22:45:01
ok one sec
Omar Malas 2022-08-07 22:45:44
note that orders is an array of order
thorefinn 2022-08-07 22:46:04
No problem
akshay sardana 2022-08-07 22:46:27
Did you define customer table name in auth file?
Omar Malas 2022-08-07 22:46:39
yes the customer line works
akshay sardana 2022-08-07 22:46:46
And are you logged in?
Omar Malas 2022-08-07 22:46:54
I’ve used it a lot
Omar Malas 2022-08-07 22:47:05
yes
Omar Malas 2022-08-07 22:47:18
it’s working fine on local idk what the problem is
thorefinn 2022-08-07 22:47:19
Did the solution i gave worked?
akshay sardana 2022-08-07 22:47:20
Print with id
Omar Malas 2022-08-07 22:47:28
one sec
akshay sardana 2022-08-07 22:47:56
Print auth guard customer only
thorefinn 2022-08-07 22:47:59
Put this instead of return response()
thorefinn 2022-08-07 22:49:04
That might be the problem that customer he is logged in with does not have any order and that’s why the json encoding is giving error
Omar Malas 2022-08-07 22:49:06
empty response
thorefinn 2022-08-07 22:49:35
Because there are no orders
thorefinn 2022-08-07 22:49:56
Do some dummy entry in database for the customer you are logged in with
Omar Malas 2022-08-07 22:50:06
not possible
databases match too
databases match too
akshay sardana 2022-08-07 22:50:12
No it should print blank array if no orders are found
thorefinn 2022-08-07 22:50:25
Yes
akshay sardana 2022-08-07 22:50:26
Issue is in auth guard customer
thorefinn 2022-08-07 22:50:35
Is it blank space?
Omar Malas 2022-08-07 22:50:35
I have orders
Omar Malas 2022-08-07 22:50:50
yes
thorefinn 2022-08-07 22:51:07
There are no brackets?
Omar Malas 2022-08-07 22:51:12
no
thorefinn 2022-08-07 22:51:50
Then the problem is with authentication
Omar Malas 2022-08-07 22:52:29
printed the user
thorefinn 2022-08-07 22:52:38
Try giving one hard-coded customer ID in the function and if the result comes then the problem is with authentication
Omar Malas 2022-08-07 22:52:41
it returned the correct user
Omar Malas 2022-08-07 22:53:01
ok one sec
thorefinn 2022-08-07 22:54:12
$orders = Order::where(‘customer_id’,<customer_id>)->orderByDesc(‘created_at’)->get();
Omar Malas 2022-08-07 22:54:20
same old error
Omar Malas 2022-08-07 22:54:42
yeah I tried that