Closed acodercat closed 6 years ago
I don’t understand your question?
in model I wanna define validationAttribute
"App\Family\Domain\Model\FamilyMemberModel and Watson\Validating\ValidatingTrait define the same property ($validationAttributeNames) in the composition of App\Family\Domain\Model\FamilyMemberModel. However, the definition differs and is considered incompatible. Class was composed"
Could be because you're using public
instead of protected
. You're really going to have to supply more than a fraction of a code sample of you want help
<?php
/**
* Created by IntelliJ IDEA.
* User: codercat
* Date: 2018/5/21
* Time: 17:31
*/
namespace App\Family\Domain\Model;
use Watson\Validating\ValidatingTrait;
use App\Common\Model\BaseModel;
use App\Family\Domain\Exceptions\DuplicateBindException;
class FamilyMemberModel extends BaseModel
{
use ValidatingTrait;
protected $table = 'family_member';
protected $fillable = ['owner_id', 'age', 'owner_relationship', 'sex', 'mobile', 'fullname','id_card_no','health_card_no','is_auth'];
protected $rules = [
'mobile' => 'bail|required|mobile',
'fullname' => 'bail|required',
'sex' => 'bail|required|in:male,female',
'age' => 'bail|nullable|integer|between:0,130',
'owner_relationship' => 'bail|nullable|in:self,children,other,husband,wife,mother,daughter,father',
'id_card_no' => 'bail|nullable|id_card_no|unique:family_member',
];
protected $validationAttributeNames = [
'mobile' => '手机号',
'fullname' => '姓名',
];
}
thanks
Did switching to protected
solve the issue? If not could you provide the complete stack trace of the error.
How to do switching to protected
$validationAttributeNames is protected
In your initial example you had it as public
, when it was supposed to be protected
. Now that you've changed it to protected
does the problem you were having still persist?
error :"App\Family\Domain\Model\FamilyMemberModel and Watson\Validating\ValidatingTrait define the same property ($validationAttributeNames) in the composition of App\Family\Domain\Model\FamilyMemberModel. However, the definition differs and is considered incompatible. Class was composed"
Cool, I understand what you're running into now. Found the issue and pushed a fix in 3.1.4
. It might take a little while to become available on Composer but when you pull in the new version you should be good to go. Let me know if it doesn't resolve the issue for you.
I wanna in my model like this