Skip to content
Advertisement

Object of class IlluminateDatabaseEloquentBuilder could not be converted to string laravel 7

I have been trying to debug a problem for the past two days, my code, as follows, is first attempting to retrieve the category by its:

Controller

JavaScript

UserTransaction.php

JavaScript

index.blade.php

JavaScript

I see this error

Object of class IlluminateDatabaseEloquentBuilder could not be converted to string (View: C:xampp3htdocsprojectswebafratessa-adminModulesTransactionResourcesviewsadminindex.blade.php)

Advertisement

Answer

I think you need to modify your query

JavaScript

also make sure $stats['done'] return object.you should fetch like $stats['done']->status

also you can improve your code a bit

create a scope method in your model

JavaScript

then you can access like this

JavaScript

Also you can keep status array in constant separately in config or you have to create each scope for each status

Updated Since you are looking for count of the status

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement