academico-sis /
academico
| 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
Bug
introduced
by
Loading history...
|
|||
| 23 | $period = Period::get_default_period(); |
||
| 24 | } else { |
||
| 25 | $period = Period::find($period_id); |
||
| 26 | } |
||
| 27 | |||
| 28 | return $period; |
||
| 29 | } |
||
| 30 | } |
||
| 31 |