Heimdall/app/Application.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2018-10-18 14:59:38 +00:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Application extends Model
{
2018-10-25 13:42:14 +00:00
public $incrementing = false;
protected $primaryKey = 'appid';
2018-10-18 14:59:38 +00:00
//
2018-10-19 14:10:05 +00:00
public function icon()
{
if(!file_exists(storage_path('app/public/'.$this->icon))) {
$img_src = app_path('SupportedApps/'.$this->name.'/'.str_replace('icons/', '', $this->icon));
$img_dest = storage_path('app/public/'.$this->icon);
//die("i: ".$img_src);
@copy($img_src, $img_dest);
}
2018-10-21 11:39:12 +00:00
return $this->icon;
}
public function iconView()
{
return asset('storage/'.$this->icon);
2018-10-19 14:10:05 +00:00
}
public function defaultColour()
{
// check if light or dark
if($this->tile_background == 'light') return '#fafbfc';
return '#161b1f';
}
public function class()
{
$name = $this->name;
$name = preg_replace('/\PL/u', '', $name);
$class = '\App\SupportedApps\\'.$name.'\\'.$name;
2018-10-19 14:10:05 +00:00
return $class;
}
2018-10-21 11:39:12 +00:00
2018-10-23 14:53:56 +00:00
public static function applist()
{
$list = [];
2018-11-05 21:03:42 +00:00
$all = self::orderBy('name')->get()->sortBy('name', SORT_NATURAL|SORT_FLAG_CASE);
2018-10-23 14:53:56 +00:00
$list['null'] = 'None';
foreach($all as $app) {
$name = $app->name;
$name = preg_replace('/\PL/u', '', $name);
$list['\App\SupportedApps\\'.$name.'\\'.$name] = $app->name;
2018-10-23 14:53:56 +00:00
}
return $list;
}
2018-10-21 11:39:12 +00:00
2018-10-18 14:59:38 +00:00
}