weekStartsAt = $weekStartsAt ?? Carbon::MONDAY; $this->weekEndsAt = $this->weekStartsAt === Carbon::MONDAY ? Carbon::SUNDAY : collect([0, 1, 2, 3, 4, 5, 6])->get($this->weekStartsAt + 6 - 7); $initialYear = $initialYear ?? Carbon::today()->year; $initialMonth = $initialMonth ?? Carbon::today()->month; $this->startsAt = Carbon::createFromDate($initialYear, $initialMonth, 1)->startOfDay(); $this->endsAt = $this->startsAt->clone()->endOfMonth()->startOfDay(); $this->calculateGridStartsEnds(); } public function calculateGridStartsEnds() { $this->gridStartsAt = $this->startsAt->clone()->startOfWeek($this->weekStartsAt); $this->gridEndsAt = $this->endsAt->clone()->endOfWeek($this->weekEndsAt); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $curUser = Auth::user(); $fullGridPeriod = CarbonPeriod::create( $this->gridStartsAt, '1 day', $this->gridEndsAt ); $filledDays = Diary::where('user_id', $curUser->id) ->whereMonth('date', now()->month) ->get() ->keyBy('date'); return view( 'calendar.index', [ 'fullGridPeriod' => $fullGridPeriod, 'currentLocale' => LaravelLocalization::getCurrentLocale(), 'filledDays' => $filledDays, 'curUser' => $curUser, ] ); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { } /** * Store a newly created resource in storage. * * @return \Illuminate\Http\Response */ public function store(Request $request) { } /** * Display the specified resource. * * @return \Illuminate\Http\Response */ public function show(Calendar $calendar) { } /** * Show the form for editing the specified resource. * * @return \Illuminate\Http\Response */ public function edit(Calendar $calendar) { } /** * Update the specified resource in storage. * * @return \Illuminate\Http\Response */ public function update(Request $request, Calendar $calendar) { } /** * Remove the specified resource from storage. * * @return \Illuminate\Http\Response */ public function destroy(Calendar $calendar) { } }