laravel get all data from table code example
Example 1: how to get data from a table in laravel
use Illuminate\Support\Facades\DB;
class UserController extends Controller
{
public function index()
{
$users = DB::table('users')->select('id','name','email')->get();
return view('some-view')->with('users', $users);
}
}
Example 2: get all data eloquent laravel
Blog::all();
//example usage.
$posts = Blog::all();
Example 3: laravel where
$users = DB::table('users')
->whereDate('created_at', '2016-12-31')
->get();