Answers for "laravel get all table data"

PHP
0

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);
    }
}
Posted by: Guest on October-22-2020
0

get all tables laravel

$tables = DB::select('SHOW TABLES');
foreach($tables as $table)
{
      echo $table->Tables_in_db_name;
}
Posted by: Guest on June-28-2021
2

get all data eloquent laravel

Blog::all();

//example usage.
$posts = Blog::all();
Posted by: Guest on October-28-2020

Code answers related to "laravel get all table data"

Browse Popular Code Answers by Language