Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to get data from a table in laravel

use IlluminateSupportFacadesDB;

class UserController extends Controller
{
    public function index()
    {
        $users = DB::table('users')->select('id','name','email')->get();

        return view('some-view')->with('users', $users);
    }
}
Comment

get from table laravel

$users = DB::table('users')->get();
 
foreach ($users as $user) {
    echo $user->name;
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel csrf token mismatch postman 
Php :: php append element to array 
Php :: current time input field in laravel form 
Php :: laravel 8 foreign key migration 
Php :: random string generator php 
Php :: php link to page 
Php :: remove item from collection 
Php :: laravel controller store 
Php :: laravel change foreign key name 
Php :: foreign key laravel migration 
Php :: laravel get image extension 
Php :: hasone relation in laravel 
Php :: send attachment in mail php 
Php :: php array check value exists 
Php :: php catch all exceptions 
Php :: comparing floats php 
Php :: php upload file 
Php :: how to make classess in php 
Php :: ACF Photo Gallery Output 
Php :: timezone php 
Php :: php check if string contains words from array 
Php :: Passing PHP Arrays to JavaScript 
Php :: laravel chunk select 
Php :: prevent xss php 
Php :: php if negative make positive 
Php :: eloquent limit 
Php :: users not having any role laravel spatie 
Php :: how to join two tables in laravel 
Php :: laravel collection push 
Php :: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =