simple select query in laravel

In Laravel We Can get data from database using select query

in below we will give simple query to select data from database

$results = DB::table('region')->select('regionname', 'regionid')
->where('countryId', $CountryID)
->get();

This will return you an array of stdClass objects that you can access properties from:

foreach($results as $result)
{
    echo $result->regionid;
}
if the Above Code Not Works Then Try The Below Code

Running A Select Query

$results = DB::select('select * from users where id = ?', [1]);

The select method will always return an array of results.

You may also execute a query using named bindings:

$results = DB::select('select * from users where id = :id', ['id' => 1]);