[WIP] Setup of skeleton
This commit is contained in:
60
app/Repositories/Applications.php
Normal file
60
app/Repositories/Applications.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
use App\Models\Application;
|
||||
|
||||
use App\Repositories\ApplicationPages;
|
||||
use App\Repositories\Languages;
|
||||
|
||||
class Applications
|
||||
{
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Application::findOrFail($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getCurrent()
|
||||
{
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
$app = isset($route[0]) ? $route[0] : null;
|
||||
$page = isset($route[1]) ? $route[1] : null;
|
||||
$action = isset($route[2]) ? $route[2] : null;
|
||||
|
||||
if (self::getBySlug($app)) {
|
||||
$data['current'] = self::getBySlug($app)->toArray();
|
||||
$application_id = $data['current']['id'];
|
||||
$data['page'] = ApplicationPages::getBySlug($application_id, $page);
|
||||
$data['pages'] = ApplicationPages::getActiveByApplication($application_id);
|
||||
$data['action'] = $action;
|
||||
} else {
|
||||
$data['current']['slug'] = $app;
|
||||
}
|
||||
$data['langs'] = Languages::getActive();
|
||||
$data['lang'] = Languages::getCurrent();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getActives()
|
||||
{
|
||||
return Application::active()->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getActivesWithModules()
|
||||
{
|
||||
return Application::with('modules')->active()->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getVisibles()
|
||||
{
|
||||
return Application::visible()->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getBySlug($slug)
|
||||
{
|
||||
return Application::active()->bySlug($slug)->first();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user