Archived
1
0
Fork 0
This repository has been archived on 2021-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
ifnews/app/Models/Language.php

29 lines
609 B
PHP
Raw Normal View History

2019-09-12 20:03:56 +03:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Game;
use App\Models\Tag;
class Language extends Model
{
2019-11-30 08:08:17 +02:00
protected $table = 'languages';
public $timestamps = false;
2019-09-12 20:03:56 +03:00
public function games() {
return $this->belongsToMany(Game::class, 'languages_games');
}
2019-11-30 08:08:17 +02:00
public static function findByCode($code) {
return self::where('code', $code)->first();
}
2020-10-23 11:50:02 +03:00
public static function findByTitle($title) {
$term = mb_strtolower($title);
return self::whereRaw('LOWER(title_en) = ?', $term)
->orWhereRaw('LOWER(title_ru) = ?',$term)
->first();
}
2019-09-12 20:03:56 +03:00
}