29 lines
609 B
PHP
29 lines
609 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\Game;
|
|
use App\Models\Tag;
|
|
|
|
class Language extends Model
|
|
{
|
|
protected $table = 'languages';
|
|
public $timestamps = false;
|
|
|
|
public function games() {
|
|
return $this->belongsToMany(Game::class, 'languages_games');
|
|
}
|
|
|
|
public static function findByCode($code) {
|
|
return self::where('code', $code)->first();
|
|
}
|
|
|
|
public static function findByTitle($title) {
|
|
$term = mb_strtolower($title);
|
|
return self::whereRaw('LOWER(title_en) = ?', $term)
|
|
->orWhereRaw('LOWER(title_ru) = ?',$term)
|
|
->first();
|
|
}
|
|
}
|