Issues (350)

app/Traits/PeriodSelection.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App\Traits;
4
5
use App\Models\Period;
6
use Illuminate\Http\Request;
7
8
trait PeriodSelection
9
{
10
    public $currentPeriod;
11
12
    public function __construct()
13
    {
14
        if (Period::count() > 0) {
15
            $this->currentPeriod = Period::get_default_period()->id;
16
        }
17
    }
18
19
    protected function selectPeriod(Request $request)
20
    {
21
        $period_id = $request->query('period');
22
        if ($period_id == null) {
0 ignored issues
show
It seems like you are loosely comparing $period_id of type array|null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
23
            $period = Period::get_default_period();
24
        } else {
25
            $period = Period::find($period_id);
26
        }
27
28
        return $period;
29
    }
30
}
31