Re-engineered with Laravel
This commit is contained in:
51
app/Models/Frame.php
Normal file
51
app/Models/Frame.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Frame extends Model
|
||||
{
|
||||
/**
|
||||
* Fetch a specific frame from the database
|
||||
*
|
||||
* @param int $page
|
||||
* @param string $frame
|
||||
* @return mixed
|
||||
*/
|
||||
public function fetch(int $page,string $frame): \App\Classes\Frame
|
||||
{
|
||||
if ($page == '999' and $frame == 'a')
|
||||
{
|
||||
return new \App\Classes\Frame(\App\Classes\Frame::testFrame());
|
||||
}
|
||||
|
||||
return new \App\Classes\Frame($this->where('frame_id',$page)->where('subframe_id',$frame)->firstOrFail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the frame cost
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCostAttribute()
|
||||
{
|
||||
// @todo NOT in DB
|
||||
return rand(0,999);
|
||||
}
|
||||
|
||||
public function hasFlag(string $flag)
|
||||
{
|
||||
// @todo When flags is in the DB update this.
|
||||
return isset($this->flags) ? in_array($flag,$this->flags,FALSE) : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frame Types
|
||||
*/
|
||||
public function type()
|
||||
{
|
||||
// @todo in DB
|
||||
return isset($this->frametype) ? $this->frametype : 'i';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user