how to get data from laravel select method 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: laravel db inserr
$id = DB::table('users')->insertGetId(
['email' => '[email protected]', 'votes' => 0]
);