1

I have a column in my database called exists, but when I try to use

$model->exists

Laravel checks if the record exists rater return the value of exists.

Is their any way to tell Laravel not to do this on that particular model?

Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
phper
  • 307
  • 2
  • 12

2 Answers2

2

As suggested earlier, renaming your column would be a good idea, because it's a reserved keyword in most database servers.

To answer your question though, you can use $model->getAttribute('exists') to get the value of a model attribute.

Source

3472948
  • 801
  • 4
  • 15
0

There's another way to do this as well; set a variable to the name of your field, then access it this way:

$fieldname = 'exists'; $model->$fieldname;

JayEdgar
  • 196
  • 2
  • 10