1$collection = collect([1, 2, 3, 4]);
2
3$filtered = $collection->filter(function ($value, $key) {
4 return $value > 2;
5});
6
7$filtered->all();
8
9// [3, 4]
1$collection = collect([1, 1, 2, 2, 3, 4, 2]);
2
3$unique = $collection->unique();
4
5$unique->values()->all();
6
7// [1, 2, 3, 4]
1/**
2 * Store a new blog post.
3 *
4 * @param Request $request
5 * @return Response
6 */
7
8public function store(Request $request)
9{
10 $validatedData = $request->validate([
11 'title' => 'required|unique:posts|max:255',
12 'body' => 'required',
13 ]);
14
15 // The blog post is valid...
16}
1'required|email|unique:company_users,email_address,NULL,id,company_id,' . $request->company_id
2