This commit is contained in:
@@ -12,4 +12,23 @@ class Tla extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['abbreviation', 'hint', 'used'];
|
||||
|
||||
public static function GetCurrentTla( string $language ) : Tla {
|
||||
$tla = Tla::where('used', date("Y-m-d"))
|
||||
->where('language', $language)
|
||||
->first();
|
||||
|
||||
if ( is_null($tla) ) {
|
||||
$tla = Tla::where('language', $language)
|
||||
->where('used', NULL)
|
||||
->inRandomOrder()
|
||||
->first();
|
||||
|
||||
$tla->used = date("Y-m-d");
|
||||
$tla->save();
|
||||
}
|
||||
|
||||
|
||||
return $tla;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user