A
A
Apostol632020-02-19 15:53:48
Laravel
Apostol63, 2020-02-19 15:53:48

Why session id from database is 0?

Hello!

I record my sessions in the database.
5e4d2dda09fbf910872545.png

But when I want to get them

class sessions extends Model {
    protected $table = 'sessions';
    public function getAll() {
        return $this->get()->toArray();
    }
}

class testController extends Controller { 
    public function midd(Request $request) {
        $x = new Sessions();
        $c = $x->getAll();
        print_r($c, 1);
    }
}


Then the following answer is returned to me:
5e4d2eca44e42665245962.png

But if I request data from the database like this: Then everything is in order and the id is the same as in the database ... What is the difference here?
$data = DB::table('sessions')->get();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2020-02-19
@JhaoDa

Because you need to read the eloquent documentation, section “Primary keys”. And using the search is also very useful.

A
Alexander Aksentiev, 2020-02-19
@Sanasol

patamuzhda string id is pornography

class Flight extends Model
{
    /**
     * Indicates if the IDs are auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;
}

https://laravel.com/docs/5.8/eloquent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question