How do I get User data in Array in Laravel

In this tutorial im going to learn how to get all user data in array.

First to create Controller

php artisan make:controller Youtube

Next to create Route go to web.php.

Route::get('/joins','Youtube@index');

Go to your controller Youtube.php and paste below code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class Youtube extends Controller
{
public function index()
{
$data=DB::table('users')->get()->toArray();
echo "<pre>";
print_r($data);
}
}

Now run below code.

http://127.0.0.1:8000/joins

Now data get successully from Users Table. Thanks đź‘Ťđź‘Ť

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store