Moved server out into its own class in preparation for other server instances

This commit is contained in:
Deon George
2018-12-07 16:19:51 +11:00
parent 67b2382c84
commit 6c91c69bd9
6 changed files with 868 additions and 797 deletions

28
app/Models/Mode.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class Mode extends Model
{
/**
* Return our server instance
*/
public function server()
{
switch ($this->name) {
case 'Ansi':
case 'VideoTex':
$class = 'App\\Classes\\Server\\'.$this->name;
break;
default:
throw new \Exception('Unknown server type: '.$this->name);
}
return new $class;
}
}