有条件地应用属性
public function toArray($request) {
return [
'name' => $this->name,
'breed' => $this->breed,
'rating' => $this->when(Auth::user()->canSeeRatings(), 12),
];
}Last updated
public function toArray($request) {
return [
'name' => $this->name,
'breed' => $this->breed,
'rating' => $this->when(Auth::user()->canSeeRatings(), 12),
];
}Last updated