Laravel - Query Builder - Raw Expressions
Sometimes you may need to insert an arbitrary string into a query. To create a raw string expression, you may use the
raw method provided by the
$users = DB::table('users') ->select(DB::raw('count(*) as user_count, status')) ->where('status', '<>', 1) ->groupBy('status') ->get();
Raw statements will be injected into the query as strings, so you should be extremely careful to avoid creating SQL injection vulnerabilities.