2018-01-29 12:41:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2018-02-01 23:10:08 +00:00
|
|
|
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
2018-02-03 15:46:14 +00:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-02-01 23:10:08 +00:00
|
|
|
|
2018-01-29 12:41:57 +00:00
|
|
|
|
|
|
|
class Item extends Model
|
|
|
|
{
|
2018-02-03 15:46:14 +00:00
|
|
|
use SoftDeletes;
|
|
|
|
|
2018-01-29 12:41:57 +00:00
|
|
|
//
|
2018-02-01 14:45:59 +00:00
|
|
|
protected $fillable = [
|
2018-02-03 00:22:42 +00:00
|
|
|
'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order'
|
2018-02-01 14:45:59 +00:00
|
|
|
];
|
2018-02-01 23:10:08 +00:00
|
|
|
|
2018-02-03 15:46:14 +00:00
|
|
|
/**
|
|
|
|
* The attributes that should be mutated to dates.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
2018-02-01 23:10:08 +00:00
|
|
|
public static function supportedList()
|
|
|
|
{
|
|
|
|
return [
|
2018-02-07 15:43:29 +00:00
|
|
|
'Duplicati' => \App\SupportedApps\Duplicati::class,
|
|
|
|
'Emby' => \App\SupportedApps\Emby::class,
|
2018-02-13 18:29:15 +00:00
|
|
|
'Home Assistant' => \App\SupportedApps\HomeAssistant::class,
|
|
|
|
'Jackett' => \App\SupportedApps\Jackett::class,
|
2018-02-11 13:22:06 +00:00
|
|
|
'Jdownloader' => \App\SupportedApps\Jdownloader::class,
|
2018-02-11 12:41:17 +00:00
|
|
|
'Mcmyadmin' => \App\SupportedApps\Mcmyadmin::class,
|
2018-02-11 13:22:06 +00:00
|
|
|
'Nextcloud' => \App\SupportedApps\Nextcloud::class,
|
2018-02-13 18:29:15 +00:00
|
|
|
'NZBGet' => \App\SupportedApps\Nzbget::class,
|
2018-02-11 13:09:54 +00:00
|
|
|
'Openhab' => \App\SupportedApps\Openhab::class,
|
2018-02-13 18:29:15 +00:00
|
|
|
'pFsense' => \App\SupportedApps\Pfsense::class,
|
2018-02-14 00:04:06 +00:00
|
|
|
'Netdata' => \App\SupportedApps\Netdata::class,
|
2018-02-07 15:43:29 +00:00
|
|
|
'Pihole' => \App\SupportedApps\Pihole::class,
|
2018-02-05 20:59:38 +00:00
|
|
|
'Plex' => \App\SupportedApps\Plex::class,
|
2018-02-09 21:06:19 +00:00
|
|
|
'Plexpy' => \App\SupportedApps\Plexpy::class,
|
2018-02-11 13:00:36 +00:00
|
|
|
'Plexrequests' => \App\SupportedApps\Plexrequests::class,
|
2018-02-07 15:43:29 +00:00
|
|
|
'Portainer' => \App\SupportedApps\Portainer::class,
|
2018-02-13 22:46:36 +00:00
|
|
|
'Proxmox' => \App\SupportedApps\Proxmox::class,
|
2018-02-13 18:29:15 +00:00
|
|
|
'Radarr' => \App\SupportedApps\Radarr::class,
|
2018-02-08 22:02:28 +00:00
|
|
|
'Sabnzbd' => \App\SupportedApps\Sabnzbd::class,
|
2018-02-13 18:29:15 +00:00
|
|
|
'Sonarr' => \App\SupportedApps\Sonarr::class,
|
2018-02-11 12:12:42 +00:00
|
|
|
'Traefik' => \App\SupportedApps\Traefik::class,
|
2018-02-11 13:22:06 +00:00
|
|
|
'UniFi' => \App\SupportedApps\Unifi::class,
|
2018-02-01 23:10:08 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
public static function supportedOptions()
|
|
|
|
{
|
|
|
|
return array_keys(self::supportedList());
|
|
|
|
}
|
2018-02-03 00:22:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scope a query to only include pinned items.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
|
|
* @return \Illuminate\Database\Eloquent\Builder
|
|
|
|
*/
|
|
|
|
public function scopePinned($query)
|
|
|
|
{
|
|
|
|
return $query->where('pinned', 1);
|
|
|
|
}
|
2018-02-06 20:41:29 +00:00
|
|
|
|
|
|
|
public function getConfigAttribute()
|
|
|
|
{
|
|
|
|
$output = null;
|
2018-02-09 08:28:20 +00:00
|
|
|
$view = null;
|
2018-02-06 20:41:29 +00:00
|
|
|
if(isset($this->description) && !empty($this->description)){
|
|
|
|
$output = json_decode($this->description);
|
2018-02-09 08:40:13 +00:00
|
|
|
$output = is_object($output) ? $output : new \stdClass();
|
2018-02-06 20:41:29 +00:00
|
|
|
if(isset($output->type) && !empty($output->type)) {
|
|
|
|
$class = $output->type;
|
|
|
|
$sap = new $class();
|
|
|
|
$view = $sap->configDetails();
|
2018-02-08 20:00:24 +00:00
|
|
|
$output->view = $view;
|
2018-02-06 20:41:29 +00:00
|
|
|
}
|
2018-02-09 08:40:13 +00:00
|
|
|
if(!isset($output->dataonly)) $output->dataonly = '0';
|
2018-02-08 20:00:24 +00:00
|
|
|
|
2018-02-06 20:41:29 +00:00
|
|
|
}
|
|
|
|
return (object)$output;
|
|
|
|
}
|
2018-02-08 20:58:07 +00:00
|
|
|
public static function checkConfig($config)
|
|
|
|
{
|
|
|
|
if(empty($config)) {
|
|
|
|
$config = null;
|
|
|
|
} else {
|
|
|
|
$store = false;
|
2018-02-09 00:05:37 +00:00
|
|
|
//die(var_dump($config));
|
2018-02-08 20:58:07 +00:00
|
|
|
foreach($config as $key => $check) {
|
|
|
|
if($key == 'type') continue;
|
2018-02-09 00:05:37 +00:00
|
|
|
if($key == 'dataonly') continue;
|
|
|
|
if(!empty($check) && $check != '0') {
|
2018-02-08 20:58:07 +00:00
|
|
|
$store = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-02-09 00:05:37 +00:00
|
|
|
//die(var_dump($store))
|
2018-02-08 20:58:07 +00:00
|
|
|
|
|
|
|
$config['enabled'] = ($store) ? true : false;
|
|
|
|
$config = json_encode($config);
|
|
|
|
}
|
|
|
|
return $config;
|
|
|
|
|
|
|
|
}
|
2018-01-29 12:41:57 +00:00
|
|
|
}
|