Answer the question
In order to leave comments, you need to log in
How to hide fields when displaying in a collection in Laravel API Resources?
There is, for example, a route for displaying a list of articles and a route for displaying a specific article:
public function index()
{
return new ArticleCollection(Article::all());
}
public function show(Article $article)
{
return new ArticleResource($article);
}
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'content' => $this->content,
];
}
public function toArray($request)
{
return [
ArticleResource::collection($this->collection),
];
}
{
"data": [
{
"id": 1,
"title": "Заголовок 1"
},
{
"id": 2,
"title": "Заголовок 2"
}
]
}
{
"data": {
"id": 1,
"title": "Заголовок 1",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
}
}
Answer the question
In order to leave comments, you need to log in
Found this solution . Maybe not super convenient, but solves my problem.
public function toArray($request)
{
return $this->collection
->map
->toArray($request, true)
->all();
}
public function toArray($request, $isCollection = false)
Why don't you specify only what you need in select(id, title), why pull out everything from the database to hide it later?
From the picture it is not clear what parallax affects. Angle of inclination?
And according to the subject: after with gradient/borders or svg
You can skew the block with CSS transform:;
Parallax or the simplest - background-position:fixed;
Or hang a js scroll to change the angle of the transform property
There is also an interesting parallax library with a lot of features - markdalgleish.com/projects/stellar.js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question