Moved server out into its own class in preparation for other server instances
This commit is contained in:
28
app/Models/Mode.php
Normal file
28
app/Models/Mode.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user