Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

If you're passing the id as a route parameter, you can do something as simple as this:

$this->id;

If you are passing it as an input, then you can do either one of these methods:

$this->get('id');
$this->input('id');
0

Not passing any ID's, just the slug. So I guess I need to do a where request to get the ID.

But when I try: 'title'=>'required|between:3,20|unique:subjects,title,'.Subject::whereTitle($this->get('title'))->first()->id, (title is unique too) I get: Trying to get property of non-object

Whenever anything other than the current title is entered.

Edit: I'll just pass the ID as a route through a hidden field, guess its simpler.

Thank-you

Last updated 9 years ago.
0

If you want to check the title, you can do this though.

'title'=>'required|between:3,20|unique:subjects,title,' . $this->get('title') . ',title',

So, to break this down, it basically does this.

  1. The title has to be unique in the subjects table and in the title column.
  2. $this->get('title') gets the title that you are passing in from the form.
  3. Normally, people pass the id and so Laravel automatically assumes that whatever argument you are passing is the id of the table. However, since you are passing in the title (not the id), you have to specify that at the end.
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Osiruss osiruss Joined 27 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.