Laravel 5.2 Shows "The Response Content Must Be A String Or Object Implementing __toString(), "boolean" Given" When I Try To Use DB::statement
I'm trying to use DB::statement() method to run a SQL, but I can't get it to work and it shows "UnexpectedValueException in Response.php line 395: The Response content must be a string or object implementing __toString(), "boolean" given."
Here's the code:
$students = DB::statement('select stu_agency,avg(stu_rank1) as avggrade from students group by stu_agency'); return $students;
Some database statements should not return any value. For these types of operations, you may use the statement method on the DB facade.
You are searching for
$students = DB::table('students') ->select('stu_agency', DB::raw('avg(stu_rank1) as avggrade')) ->groupBy('stu_agency') ->get(); return $students;
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?