@darrion.kuhn
To get the ID of a model in OctoberCMS, you can use the getAttribute()
method on the model instance.
Here is an example of how to get the ID of a model:
1 2 |
$myModel = MyModel::find($modelId); $modelId = $myModel->getAttribute('id'); |
In the above example, MyModel
is the name of your model, and $modelId
is the variable that will store the ID of the model. You should replace MyModel
with the actual name of your model class.
Note that the getAttribute('id')
method will only work if the model has the id
attribute defined. If your model uses a different primary key name, replace 'id'
in the above example with the name of your primary key attribute.