akaunting 3.0 (the last dance)
This commit is contained in:
12
app/View/Components/Modules/Banners.php
Normal file
12
app/View/Components/Modules/Banners.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Banners extends Component
|
||||
{
|
||||
public $type = 'banners';
|
||||
|
||||
public $view = 'components.modules.banners';
|
||||
}
|
12
app/View/Components/Modules/Free.php
Normal file
12
app/View/Components/Modules/Free.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Free extends Component
|
||||
{
|
||||
public $type = 'free';
|
||||
|
||||
public $view = 'components.modules.free';
|
||||
}
|
12
app/View/Components/Modules/Installed.php
Normal file
12
app/View/Components/Modules/Installed.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Installed extends Component
|
||||
{
|
||||
public $type = 'installed';
|
||||
|
||||
public $view = 'components.modules.installed';
|
||||
}
|
31
app/View/Components/Modules/Item.php
Normal file
31
app/View/Components/Modules/Item.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Item extends Component
|
||||
{
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$model
|
||||
) {
|
||||
$this->module = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.modules.item');
|
||||
}
|
||||
}
|
257
app/View/Components/Modules/Items.php
Normal file
257
app/View/Components/Modules/Items.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\Traits\Modules;
|
||||
use App\Models\Module\Module;
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class Items extends Component
|
||||
{
|
||||
use Modules;
|
||||
|
||||
public $type;
|
||||
|
||||
public $modules;
|
||||
|
||||
public $limit;
|
||||
|
||||
public $seeMore;
|
||||
|
||||
public $installedStatus;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$model = [], $limit = 4, $seeMore = false
|
||||
) {
|
||||
$this->limit = $limit;
|
||||
$this->seeMore = $this->getSeeMore($seeMore, $model);
|
||||
$this->modules = $this->getModel($model);
|
||||
$this->installedStatus = $this->getInstalledStatus();
|
||||
|
||||
$this->view = $this->getView();
|
||||
$this->type = $this->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view($this->view);
|
||||
}
|
||||
|
||||
protected function getSeeMore($seeMore, $model)
|
||||
{
|
||||
if (empty($seeMore)) {
|
||||
return $seeMore;
|
||||
}
|
||||
|
||||
if (! empty($model) && ($model->current_page < $model->last_page)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getModel($model)
|
||||
{
|
||||
if (! empty($model)) {
|
||||
if (! empty($model->data)) {
|
||||
return $model->data;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
$model = [];
|
||||
|
||||
switch ($this->type) {
|
||||
case 'banners':
|
||||
$model = $this->getBanners();
|
||||
break;
|
||||
case 'new':
|
||||
$model = $this->getNew($this->limit);
|
||||
break;
|
||||
case 'paid':
|
||||
$model = $this->getPaid($this->limit);
|
||||
break;
|
||||
case 'free':
|
||||
$model = $this->getFree($this->limit);
|
||||
break;
|
||||
case 'pre_sale':
|
||||
$model = $this->getPreSale($this->limit);
|
||||
break;
|
||||
case 'purchased':
|
||||
$model = $this->getPurchased($this->limit);
|
||||
break;
|
||||
case 'installed':
|
||||
$model = $this->getInstalled();
|
||||
break;
|
||||
case 'no-apps':
|
||||
$model = $this->getTestimonials();
|
||||
break;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getView()
|
||||
{
|
||||
if (! empty($this->view)) {
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
return 'components.modules.items';
|
||||
}
|
||||
|
||||
protected function getBanners()
|
||||
{
|
||||
$model = $this->getBannersOfModules();
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getNew($limit)
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getNewModules([
|
||||
'query' => [
|
||||
'limit' => $limit
|
||||
]
|
||||
]);
|
||||
|
||||
if ($response) {
|
||||
$model = $response->data;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getFree($limit)
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getFreeModules([
|
||||
'query' => [
|
||||
'limit' => $limit
|
||||
]
|
||||
]);
|
||||
|
||||
if ($response) {
|
||||
$model = $response->data;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getPaid($limit)
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getPaidModules([
|
||||
'query' => [
|
||||
'limit' => $limit
|
||||
]
|
||||
]);
|
||||
|
||||
if ($response) {
|
||||
$model = $response->data;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getPreSale($limit)
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getPreSaleModules([
|
||||
'query' => [
|
||||
'limit' => $limit
|
||||
]
|
||||
]);
|
||||
|
||||
if ($response) {
|
||||
$model = $response->data;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getPurchased($limit)
|
||||
{
|
||||
$model = [];
|
||||
$data = [];
|
||||
|
||||
if ($limit != 4) {
|
||||
$data = [
|
||||
'query' => [
|
||||
'limit' => $limit
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$response = $this->getMyModules($data);
|
||||
|
||||
if ($response) {
|
||||
$model = $response;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getInstalled()
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getInstalledModules();
|
||||
|
||||
if ($response) {
|
||||
$model = $response;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getTestimonials()
|
||||
{
|
||||
$model = [];
|
||||
|
||||
$response = $this->getTestimonialModules();
|
||||
|
||||
if ($response) {
|
||||
$model = $response;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function getInstalledStatus()
|
||||
{
|
||||
$installed = Module::where('company_id', '=', company_id())->pluck('enabled', 'alias')->toArray();
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
||||
protected function getType()
|
||||
{
|
||||
if (! empty($this->type)) {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
$name = Route::currentRouteName();
|
||||
|
||||
$keys = explode('.', $name);
|
||||
|
||||
return count($keys) > 2 ? $keys[1] : last($keys);
|
||||
}
|
||||
}
|
12
app/View/Components/Modules/Nnew.php
Normal file
12
app/View/Components/Modules/Nnew.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Nnew extends Component
|
||||
{
|
||||
public $type = 'new';
|
||||
|
||||
public $view = 'components.modules.nnew';
|
||||
}
|
12
app/View/Components/Modules/NoApps.php
Normal file
12
app/View/Components/Modules/NoApps.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class NoApps extends Component
|
||||
{
|
||||
public $type = 'no-apps';
|
||||
|
||||
public $view = 'components.modules.no_apps';
|
||||
}
|
12
app/View/Components/Modules/Paid.php
Normal file
12
app/View/Components/Modules/Paid.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Paid extends Component
|
||||
{
|
||||
public $type = 'paid';
|
||||
|
||||
public $view = 'components.modules.paid';
|
||||
}
|
12
app/View/Components/Modules/PreSale.php
Normal file
12
app/View/Components/Modules/PreSale.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class PreSale extends Component
|
||||
{
|
||||
public $type = 'pre_sale';
|
||||
|
||||
public $view = 'components.modules.pre_sale';
|
||||
}
|
12
app/View/Components/Modules/Purchased.php
Normal file
12
app/View/Components/Modules/Purchased.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Modules;
|
||||
|
||||
use App\View\Components\Modules\Items as Component;
|
||||
|
||||
class Purchased extends Component
|
||||
{
|
||||
public $type = 'purchased';
|
||||
|
||||
public $view = 'components.modules.purchased';
|
||||
}
|
Reference in New Issue
Block a user