51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class OddsTable extends Model
|
|
{
|
|
public static function oddnames()
|
|
{
|
|
$res = OddsTable::get();
|
|
$arr = [];
|
|
foreach ($res as $value) {
|
|
$names = explode(',', $value->oddnames);
|
|
$fields = explode(',', $value->fieldnames);
|
|
|
|
$arr[$value->name] = array_combine($fields, $names);
|
|
}
|
|
|
|
return $arr;
|
|
}
|
|
|
|
public static function fields()
|
|
{
|
|
$res = OddsTable::get();
|
|
$arr = [];
|
|
foreach ($res as $value) {
|
|
$arr[$value->name] = explode(',', $value->oddnames);
|
|
}
|
|
|
|
return $arr;
|
|
}
|
|
|
|
public static function options_sport()
|
|
{
|
|
switch (auth()->user()->sport_id) {
|
|
case 1:
|
|
return OddsTable::where('soccer', 1)->pluck('fulltitle', 'id');
|
|
case 2:
|
|
return OddsTable::where('icehockey', 1)->pluck('fulltitle', 'id');
|
|
case 3:
|
|
return OddsTable::where('basketball', 1)->pluck('fulltitle', 'id');
|
|
case 5:
|
|
return OddsTable::where('tennis', 1)->pluck('fulltitle', 'id');
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
|
}
|