0

I want to get Id of newly added row in database. here is the code:

  public function store(Request $request)
    {
        $me = Translation::save();
        return $me->id;

    }

Translation extends Facade but this code returns error :

Trying to get property of non-object.

any idea? var_dump($me) returns bool(true)

tricky part is that Translation model contains only 1 column - id

O. Shekriladze
  • 1,346
  • 1
  • 19
  • 36

1 Answers1

2

You need to create a new object first in order to save it and retrieve its ID.

$me = new Translation();
$me->save();

return $me->id;
party-ring
  • 1,761
  • 1
  • 16
  • 38