Answers for "random numbers in laravel"

PHP
0

laravel get random number of data from database

Model::select('column')
    ->where('column','value')
    ->inRandomOrder()
    ->limit(2) // here is yours limit
    ->get();
Posted by: Guest on July-14-2021
0

random string value laravel

//select random value from array
use Illuminate\Support\Arr;

$array = [1, 2, 3, 4, 5];

$random = Arr::random($array);


//generate random string of specific length
use Illuminate\Support\Str;

$random = Str::random(40);
Posted by: Guest on September-16-2021

Browse Popular Code Answers by Language