-4

I have a problem understanding what is the use of <> in ->where('id', '<>', $id)

protected function getRelatedSlugs($slug, $id = 0){
    return Product::select('slug')
    ->where('slug', 'like', $slug.'%')
    ->where('id', '<>', $id)->get();
}
bhucho
  • 3,903
  • 3
  • 16
  • 34
  • 3
    Does this answer your question? [Reference — What does this symbol mean in PHP?](https://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – STA Oct 04 '20 at 17:11
  • @sta — Since in PHP it is just a string, not really. – Quentin Oct 04 '20 at 18:58

1 Answers1

1

See the documentation:

The second argument is an operator, which can be any of the database's supported operators

So look that up in the manual for your database.

You didn't say what database you were using, so let's look at PostgreSQL 13:

datatype <> datatype → boolean: Not equal

So it means "Where the id is not equal to the value of $id.

In other words, when you get the slugs related to the current one, you don't want to return the current one in the list.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335