Mass assignment problem


Stop me if you’ve heard this one.

So i wanted to restrict the accessible fields an entity in my app.

I looked at this example in the docs.

class Article extends Entity
protected $_accessible = [
‘title’ => true,
‘body’ => true

I found that even when i set all the fields to true i was getting an error.

Now there is a related model. There’s a booking with a related customer.

The error i get says, ‘Could not find record in bookings table’

If i do this:

class Booking extends Entity
protected $_accessible = [
‘id’ => false,
‘customer_id’ => false,
’*’ => true,

It works fine.

So the question is: What is the difference between having ‘*’ => true and having a list of all your fields set to true?

Is it the related data?

Any advice on this would be very much appreciated folks.

My guess is that since Associations are properties (you can set it a property name) you have to make it accesible OR pass the strict names in the associated key in the save (like the book says)

That sounds like the answer!

I’ll give it a shot tomorrow and see what happens.

I’ll post back when I get it working.