l5-repository icon indicating copy to clipboard operation
l5-repository copied to clipboard

Return id as Primary Key after create?

Open primangesta opened this issue 5 years ago • 4 comments

How to get id after using $this->repository->create($request->all()); ?

primangesta avatar Aug 16 '19 07:08 primangesta

@primangesta Just call ->id after create.

$this->repository->create($request->all())->id;

Minotti avatar Aug 28 '19 02:08 Minotti

@Minotti it always return null. for a while i using DB::getPdo()->lastInsertId(); but i need to know if they have function for get id

primangesta avatar Aug 29 '19 07:08 primangesta

Strange ... I tested it in my repository here and it worked ...

Minotti avatar Aug 29 '19 20:08 Minotti

could you show me your model you have set?

primangesta avatar Aug 30 '19 02:08 primangesta