openstamanager/src/Traits/RecordTrait.php

36 lines
650 B
PHP
Raw Normal View History

2018-08-11 15:37:38 +02:00
<?php
namespace Traits;
2018-11-30 19:40:06 +01:00
use Models\Module;
use Models\Plugin;
2018-08-13 10:01:15 +02:00
trait RecordTrait
2018-08-11 15:37:38 +02:00
{
2018-11-30 19:40:06 +01:00
public function getModule()
2018-08-11 15:37:38 +02:00
{
2018-11-30 19:40:06 +01:00
return !empty($this->module) ? Module::get($this->module) : null;
2018-08-11 15:37:38 +02:00
}
2018-11-30 19:40:06 +01:00
public function getPlugin()
2018-08-11 15:37:38 +02:00
{
2018-11-30 19:40:06 +01:00
return !empty($this->plugin) ? Plugin::get($this->plugin) : null;
2018-08-11 15:37:38 +02:00
}
2018-11-30 19:40:06 +01:00
public function uploads()
2018-08-11 15:37:38 +02:00
{
2018-11-30 19:40:06 +01:00
$module = $this->getModule();
$plugin = $this->getPlugin();
2018-08-11 15:37:38 +02:00
2018-11-30 19:40:06 +01:00
if (!empty($module)) {
return $module->uploads($this->id);
2018-08-11 15:37:38 +02:00
}
2018-11-30 19:40:06 +01:00
if (!empty($plugin)) {
return $plugin->uploads($this->id);
}
2018-08-11 15:37:38 +02:00
2018-11-30 19:40:06 +01:00
return collect();
2018-08-11 15:37:38 +02:00
}
}