Files
TLA/app/Models/Tla.php
T

35 lines
747 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Tla extends Model
{
protected $table = 'tla';
use HasFactory;
protected $fillable = ['acronym', 'hint', 'used', 'context'];
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;
}
}