Answers for "laravel database queries"

PHP
6

laravel db query

$users = DB::table('users')
            ->where('votes', '>', 100)
            ->orWhere(function($query) {
                $query->where('name', 'Abigail')
                      ->where('votes', '>', 50);
            })
            ->get();
Posted by: Guest on April-30-2021
0

laravel sql query

use Illuminate\Support\Facades\DB;

$users = DB::select('select * from users');

foreach ($users as $user) {
    echo $user->name;
}
Posted by: Guest on January-07-2021
2

DB::table('users')->get();

DB::select('SELECT * FROM users WHERE name = ?', array(Input::get('name')));
Posted by: Guest on October-22-2020
2

query builder laravel

use Illuminate\Database\Eloquent\Builder;

public function scopeFakePersons(Builder $query): Builder
{
  return $query->where('is_fake', 1);
}
Posted by: Guest on January-20-2021

Browse Popular Code Answers by Language