Skip to content

Commit

Permalink
#69 - fix problem with empty lectures (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHDOLEK authored Oct 2, 2023
1 parent 974abbc commit 691d394
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions app/Models/Specialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@ public static function findBySpecializationIdWitchField(int $specializationId):
*/
public static function findBySpecializationIdWitchLegend(int $specializationId): self
{
/** @var self|null $specialization */
$specialization = self::query()->with("timetable", "timetable.legend")->where("id", $specializationId)
/** @var self|null $specialization
* @phpstan-ignore-next-line
*/
$specialization = self::query()
->with([
"timetable" => function ($query): void {
$query->where("lecturer", "!=", Timetable::EMPTY_LECTURER);
},
"timetable.legend",
])
->where("id", $specializationId)
->first();

if ($specialization === null) {
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Timetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Timetable extends Model
{
use HasFactory;

private const EMPTY_LECTURER = "-";
public const EMPTY_LECTURER = "-";

protected $table = "timetable";
protected $guarded = [
Expand Down

0 comments on commit 691d394

Please sign in to comment.