@lagbox : i don't know what you mean by all of this ..!!
i already set the fillable and everything was normal and this problem suddenly happened after i made the Accessors ..
all of this to explain the situation and make the problem obvious to you ..
you can read what i did again , and you will see that everything is normal, but i don't know what cause the problem ..
and this is some dd() test :
array:9 [
"email" => "[email protected]"
"password" => "123456"
"phone" => "0321561235"
"name" => "ryan"
"api_token" => "Q3kphRxwQzcdah55yZUS9Ip6Vjt8qi09EkgrlDaRTd8jpYLGwOpqhANcW5Ce"
"status" => 1
"dashboard_access" => 0
"role" => "member"
]
array:16 [
0 => "name"
1 => "email"
2 => "password"
3 => "img"
4 => "gender"
5 => "phone"
6 => "address_ar"
7 => "address_en"
8 => "address_coordinates"
9 => "role"
10 => "dashboard_access"
11 => "status"
12 => "confirmed"
13 => "confirmation_code"
14 => "api_token"
15 => "membership_id"
]
@lagbox :
in my User model i made a construct to make dynamically hidden attributes :
and when i comment this construct, it worked again .. but idk why this cause this problem :
public function __construct()
{
// to hide unused properties in the returned josn api.
if(request()->segment(1) == 'api'){
$this->addHidden(['membership_allowed_days']);
}
}
@lagbox : it solved now as i should call the parent construct in User construct to not override the existing mass assignment attributes :)
like this :
public function __construct($attributes = [])
{
// To not override the existing mass assignment attributes
parent::__construct($attributes);
// to hide unused properties in the returned josn api.
if(request()->segment(1) == 'api'){
$this->addHidden(['membership_allowed_days']);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community