Answers for "filter array for unique values larave"

PHP
1

get unique values in laravel

$users = User::select('name')->distinct()->get();
Posted by: Guest on February-19-2021
0

laravel validation array unique values

<?php
$validator = Validator::make($request->all(), [
  'myArray' => ['required', 'array', 'min:1', 'max:100', 'distinct'],
  'myArray.*' => ['required', 'integer', 'min:1', 'max:999999']
]);

if ($validator->fails()) {
  return [
    'status' => 400,
    'response' => $validator->errors()
  ];
}

$validated = $validator->validated();

// distinct is there for the uniqunes
Posted by: Guest on March-22-2022

Code answers related to "filter array for unique values larave"

Browse Popular Code Answers by Language