Answer the question
In order to leave comments, you need to log in
How to get data in the form of an object in ELOQUENT ORM?
I can't figure out how to get data from a table as an object.
There is a table with two columns option (index field) and name. You need to get name from it where option = something.
Tried like this:
return OptionsModel::all->$name;
//либо вот так
return OptionsModel::where('option', $name)->get();
return OptionsModel::where('option', "=", $name)->get();
0 = {"option":"siteTitle","value":"WEBVOYAGER.PRO"}
Answer the question
In order to leave comments, you need to log in
The get() method returns a collection of objects, which you are trying to work with as a single object (this is what they write to you in the error).
If you obviously have one object, you need to do this:
return OptionsModel::where('option', $name)->first();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question