scope = $scope; } public function getScopeName ($scope) { return collect($this->options)->where('id', $scope)['name']; } public $options = [ ['id' => '1M', 'name' => '1 month'], ['id' => '2M', 'name' => '3 months'], ['id' => 'YTD', 'name' => 'Year to date'], ['id' => '1Y', 'name' => '1 year'], ['id' => '3Y', 'name' => '3 years'], ['id' => 'ALL', 'name' => 'All time'] ]; public ?Portfolio $portfolio; private function generateDateSeries($startDate, $endDate) { $dateArray = []; $currentDate = strtotime($startDate); $endDate = strtotime($endDate); while ($currentDate <= $endDate) { // Generate a random integer $randomInt = rand(1000, 3000); // Format the current date to 'Y-m-d' $formattedDate = date('Y-m-d', $currentDate); // Append the date and random integer to the array $dateArray[] = [$formattedDate, $randomInt]; // Move to the next day $currentDate = strtotime("+1 day", $currentDate); } return $dateArray; } public array $myChart; public function mount() { $this->myChart = [ 'series' => [ [ 'name' => 'Total Views', 'data' => $this->generateDateSeries('2024-01-01', '2024-08-01') ], [ 'name' => 'Second Views', 'data' => $this->generateDateSeries('2024-01-01', '2024-08-01') ], ], ]; } }; ?>

Performance

@foreach($options as $option) @endforeach
@php $users = App\Models\User::take(3)->get(); @endphp @foreach($users as $user) @endforeach @php $users = App\Models\User::take(3)->get(); @endphp @foreach($users as $user) @endforeach @php $users = App\Models\User::take(3)->get(); @endphp @foreach($users as $user) @endforeach @php $users = App\Models\User::take(3)->get(); @endphp @foreach($users as $user) @endforeach