forked from eatvio/eatvio-infra
static analizys update
This commit is contained in:
@@ -5,26 +5,30 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Diary;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
class CalendarController extends Controller
|
||||
{
|
||||
public $weekStartsAt;
|
||||
public string|int|null $weekStartsAt;
|
||||
|
||||
public $weekEndsAt;
|
||||
public string|int|null $weekEndsAt;
|
||||
|
||||
public $startsAt;
|
||||
public Carbon $startsAt;
|
||||
|
||||
public $endsAt;
|
||||
public Carbon $endsAt;
|
||||
|
||||
public $gridStartsAt;
|
||||
public string|int|null $gridStartsAt;
|
||||
|
||||
public $gridEndsAt;
|
||||
public string|int|null $gridEndsAt;
|
||||
|
||||
public function __construct($initialYear = null, $initialMonth = null, $weekStartsAt = null)
|
||||
{
|
||||
public function __construct(
|
||||
string|int|null $initialYear = null,
|
||||
string|int|null $initialMonth = null,
|
||||
string|int|null $weekStartsAt = null
|
||||
) {
|
||||
$this->weekStartsAt = $weekStartsAt ?? Carbon::MONDAY;
|
||||
$this->weekEndsAt = $this->weekStartsAt === Carbon::MONDAY
|
||||
? Carbon::SUNDAY
|
||||
@@ -38,13 +42,13 @@ class CalendarController extends Controller
|
||||
$this->calculateGridStartsEnds();
|
||||
}
|
||||
|
||||
public function calculateGridStartsEnds()
|
||||
public function calculateGridStartsEnds(): void
|
||||
{
|
||||
$this->gridStartsAt = $this->startsAt->clone()->startOfWeek($this->weekStartsAt);
|
||||
$this->gridEndsAt = $this->endsAt->clone()->endOfWeek($this->weekEndsAt);
|
||||
}
|
||||
|
||||
public function index(): View
|
||||
public function index(): View|ViewFactory
|
||||
{
|
||||
$curUser = Auth::user();
|
||||
$fullGridPeriod = CarbonPeriod::create(
|
||||
@@ -52,8 +56,9 @@ class CalendarController extends Controller
|
||||
'1 day',
|
||||
$this->gridEndsAt
|
||||
);
|
||||
|
||||
$filledDays = Diary::where('user_id', $curUser->id)
|
||||
->whereMonth('date', now()->month)
|
||||
->whereMonth('date', (string) now()->month)
|
||||
->get()
|
||||
->keyBy('date');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user