31 lines
964 B
PHP
31 lines
964 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Utilities\Notice;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Sport extends Model
|
|
{
|
|
public static function map($field, $reverse = false, $limit = [])
|
|
{
|
|
if (! in_array($field, ['bapi', 'bwin', 'b365', 'logi', 'magl'])) {
|
|
Notice::note('Sport::map wrong option! Possible options: bapi, bwin, b365, logi, magl', 'r', 1);
|
|
}
|
|
|
|
if ($reverse) {
|
|
if ($limit) {
|
|
return Sport::where('is_active', 1)->whereIn('id', $limit)->pluck('id', $field)->toArray();
|
|
} else {
|
|
return Sport::where('is_active', 1)->pluck('id', $field)->toArray();
|
|
}
|
|
} else {
|
|
if ($limit) {
|
|
return Sport::where('is_active', 1)->whereIn($limit, 'id')->pluck('id', $field)->toArray();
|
|
} else {
|
|
return Sport::where('is_active', 1)->pluck($field, 'id')->toArray();
|
|
}
|
|
}
|
|
}
|
|
}
|