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/Platform.php
2020-01-05 16:19:04 +07:00

26 lines
490 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Game;
class Platform extends Model
{
public $timestamps = false;
public function games() {
return $this->belongsToMany(Game::class, 'games_platforms', 'platform_id');
}
public static function findByName($name) {
$model = self::where('name', $name)->first();
if (empty($model)) {
$model = new self;
$model->name = $name;
$model->save();
}
return $model;
}
}