This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello,
with config_relation.yaml
I created a form which work well and I connect 3 tables together.
add remove button work as well and when I submit form all fields will save to 3 tables. but when I click on create button (which defined through partial) and fill forms I received mass alignment failed for model attribute 'slug'.
slug is set to unique record and it defined in rules!
what should I do at this situation!
Last updated
I found my solution and change protected $guarded = ['*'];
to protected $guarded = [];
.
I didn't found anything about it.
are there any description about protected $guarded = [];
?
I found answer about $guarded and other variables.
Controller properties
The back-end controller base class defines a number of properties that allow to configure the page appearance and manage the page security:
Property | Description |
---|---|
$fatalError | allows to store a fatal exception generated in an action method in order to display it in the view. |
$user | contains a reference to the the back-end user object. |
$suppressView | allows to prevent the view display. Can be updated in the action method or in the controller constructor. |
$params | an array of the routed parameters. |
$action | a name of the action method being executed in the current request. |
$publicActions | defines an array of actions available without the back-end user authentication. Can be overridden in the class definition. |
$requiredPermissions | permissions required to view this page. Can be set in the class definition or in the controller constructor. See users & permissions for details. |
$pageTitle | sets the page title. Can be set in the action method. |
$bodyClass | body class property used for customizing the layout. Can be set in the controller constructor or action method. |
$guarded | controller specific methods which cannot be called as actions. Can be extended in the controller constructor. |
sorry for this post
That is bad! Very bad!
You actually fixed this the wrong way. You should change the $guarded
property back to ['*']
, otherwise you are opening your application to security risks.
Instead, use the $fillable
property to specifically set the fields you want to allow to be filled. For example:
protected $guarded = ['*'];
protected $fillable = ['name', 'email'];
I'd strongly suggest you read the Laravel/Eloquent documentation in full to make sure you understand how it works before you release any code into production. There is also a great site with hundreds of video tutorials called Laracasts - it's well worth the small price each month - some of the videos are even free.
Last updated
Thanks for your suggestion and reply. Currently I'm new to laravel and october,too. I purchase laracast 1 week ago. I started lara and october together. sure, I'll not release any product when I'm newbie. Again, thanks for your helps.
1-5 of 5