37 lines
831 B
PHP
37 lines
831 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', 'language', 'used', 'context', 'submitter', 'likes', 'dislikes'];
|
|
|
|
public static function GetCurrentTla( string $language ) {
|
|
$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();
|
|
|
|
if ($tla == NULL) return NULL;
|
|
|
|
$tla->used = date("Y-m-d");
|
|
$tla->save();
|
|
}
|
|
|
|
|
|
return $tla;
|
|
}
|
|
}
|