Question: How to get data from db and how does the session work in laravel?

  backend, laravel, php

I was native PHP programmer and I start learning laravel a few days ago, and I am struggling with how to get data from the database, usually, in native, I use query and oop to connect to DB and execute queries, but in laravel it little weird and I don’t get it, example, I want to get data from the database where user_id = ‘1’.

last but not least

in native PHP I assigned auto user_id without login by using and session for example:

if (!isset($_SESSION['user_id'])){
  $id = //rnd function to generate random numbers ;
  $_SESSION['user_id'] = $id;

in laravel I don’t know how to do it, please remember that anything will help me so don’t hesitate to help me.

Source: Laravel

Leave a Reply