Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrycrocodic committed Oct 14, 2020
1 parent b1b4490 commit 98e6f4c
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"require": {
"php":"^7.2",
"barryvdh/laravel-dompdf": "0.8.*",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/CrudboosterVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class CrudboosterVersionCommand extends Command
*/
public function handle()
{
$this->info("Version : 5.4.15");
$this->info("Version : 5.5.0");
}
}
4 changes: 2 additions & 2 deletions src/commands/Mailqueues.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace crocodicstudio\crudbooster\commands;

use Cache;
use CRUDBooster;
use crocodicstudio\crudbooster\helpers\CRUDBooster;
use DB;
use Illuminate\Console\Command;
use Request;
Expand Down Expand Up @@ -35,7 +35,7 @@ public function handle()

$this->comment('Mail Queues Started '.$now);

$queues = DB::table('cms_email_queues')->where('send_at', '<=', $now)->take(25)->get();
$queues = db('cms_email_queues')->where('send_at', '<=', $now)->take(25)->get();

$this->comment('Total Queues : '.count($queues));

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getLockscreen()
public function postUnlockScreen()
{
$id = CRUDBooster::myId();
$password = Request::input('password');
$password = request('password');
$users = DB::table(config('crudbooster.USER_TABLE'))->where('id', $id)->first();

if (\Hash::check($password, $users->password)) {
Expand Down Expand Up @@ -88,7 +88,7 @@ public function postLogin()
Session::put('admin_privileges_name', $priv->name);
Session::put('admin_lock', 0);
Session::put('theme_color', $priv->theme_color);
Session::put("appname", CRUDBooster::getSetting('appname'));
Session::put("appname", get_setting('appname'));

CRUDBooster::insertLog(cbLang("log_login", ['email' => $users->email, 'ip' => Request::server('REMOTE_ADDR')]));

Expand Down
18 changes: 4 additions & 14 deletions src/controllers/CBController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


use CB;
use crocodicstudio\crudbooster\export\DefaultExportXls;
use CRUDBooster;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
Expand Down Expand Up @@ -660,22 +661,11 @@ public function postExportData()
return $pdf->stream($filename.'.pdf');
break;
case 'xls':
Excel::create($filename, function ($excel) use ($response, $filename, $paperorientation) {
$excel->setTitle($filename)->setCreator("crudbooster.com")->setCompany(CRUDBooster::getSetting('appname'));
$excel->sheet($filename, function ($sheet) use ($response, $paperorientation) {
$sheet->setOrientation($paperorientation);
$sheet->loadview('crudbooster::export', $response);
});
})->export('xls');
return Excel::download(new DefaultExportXls($response),$filename.".xls");
break;
case 'csv':
Excel::create($filename, function ($excel) use ($response, $filename, $paperorientation) {
$excel->setTitle($filename)->setCreator("crudbooster.com")->setCompany(CRUDBooster::getSetting('appname'));
$excel->sheet($filename, function ($sheet) use ($response, $paperorientation) {
$sheet->setOrientation($paperorientation);
$sheet->loadview('crudbooster::export', $response);
});
})->export('csv');

return Excel::download(new DefaultExportXls($response),$filename.".csv");
break;
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/controllers/StatisticBuilderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,25 @@ public function getDashboard()
{
$this->cbLoader();

$menus= DB::table('cms_menus')->whereRaw("cms_menus.id IN (select id_cms_menus from cms_menus_privileges where id_cms_privileges = '".CRUDBooster::myPrivilegeId()."')")->where('is_dashboard', 1)->where('is_active', 1)->first();
$menus= DB::table('cms_menus')
->whereRaw("cms_menus.id IN (select id_cms_menus from cms_menus_privileges where id_cms_privileges = '".CRUDBooster::myPrivilegeId()."')")
->where('is_dashboard', 1)
->where('is_active', 1)
->first();

$slug = str_replace("statistic_builder/show/", "", $menus->path);

$row = CRUDBooster::first($this->table, ['slug' => $slug]);
$id_cms_statistics = $row->id;
$page_title = $row->name;

return view('crudbooster::statistic_builder.show', compact('page_title', 'id_cms_statistics'));

$data = [];
$data['row'] = $row;
$data['id_cms_statistics'] = $id_cms_statistics;
$data['page_title'] = $page_title;

return view('crudbooster::statistic_builder.show',$data);
}

public function getShow($slug)
Expand Down
23 changes: 23 additions & 0 deletions src/export/DefaultExportXls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


namespace crocodicstudio\crudbooster\export;


use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class DefaultExportXls implements FromView
{
private $data;

public function __construct($data)
{
$this->data = $data;
}

public function view(): View
{
return view("crudbooster::export",$this->data);
}
}
7 changes: 4 additions & 3 deletions src/helpers/CBRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ private static function userControllerRoute() {
'namespace' => 'App\Http\Controllers',
], function () {

Route::get('/',function () {});

$modules = [];
try {
// Todo: change table
Expand Down Expand Up @@ -104,11 +102,14 @@ private static function cbRoute() {
// Todo: change table
if (request()->is(config('crudbooster.ADMIN_PATH'))) {
$menus = db('cms_menus')->where('is_dashboard', 1)->first();
if (! $menus) {
if ($menus) {
Route::get('/', 'StatisticBuilderController@getDashboard');
} else {
CRUDBooster::routeController('/', 'AdminController', static::$cb_namespace);
}
}


CRUDBooster::routeController('api_generator', 'ApiCustomController', static::$cb_namespace);

// Todo: change table
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ function now() {
|
*/

if(!function_exists('get_setting')) {
/**
* @param $key
* @param null $default
* @return bool
*/
function get_setting($key, $default = null) {
$setting = \crocodicstudio\crudbooster\helpers\CB::getSetting($key);
return $setting || $default;
}
}

if(!function_exists('str_random')) {
function str_random($length = 16) {
return \Illuminate\Support\Str::random($length);
Expand Down
2 changes: 1 addition & 1 deletion src/views/admin_template.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
@if($module)
<h1>
<!--Now you can define $page_icon alongside $page_tite for custom forms to follow CRUDBooster theme style -->
<i class='{!! ($page_icon)?:$module->icon !!}'></i> {!! ($page_title)?:$module->name !!} &nbsp;&nbsp;
<i class='{!! ($page_icon)?:$module->icon !!}'></i> {!! ucwords(($page_title)?:$module->name) !!} &nbsp;&nbsp;

<!--START BUTTON -->

Expand Down
1 change: 0 additions & 1 deletion src/views/home.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@extends('crudbooster::admin_template')

@section('content')


Expand Down
8 changes: 4 additions & 4 deletions src/views/menus_management.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class='fa fa-check'></i> Menu Saved !</span>
<div class='{{$menu->is_dashboard?"is-dashboard":""}}' title="{{$menu->is_dashboard?'This is setted as Dashboard':''}}">
<i class='{{($menu->is_dashboard)?"icon-is-dashboard fa fa-dashboard":$menu->icon}}'></i> {{$menu->name}} <span
class='pull-right'><a class='fa fa-pencil' title='Edit'
href='{{route("MenusControllerGetEdit",["id"=>$menu->id])}}?return_url={{urlencode(Request::fullUrl())}}'></a>&nbsp;&nbsp;<a
href='{{route("MenusControllerGetEdit")."/".$menu->id }}?return_url={{urlencode(Request::fullUrl())}}'></a>&nbsp;&nbsp;<a
title='Delete' class='fa fa-trash'
onclick='{{CRUDBooster::deleteConfirm(route("MenusControllerGetDelete",["id"=>$menu->id]))}}'
onclick='{{CRUDBooster::deleteConfirm(route("MenusControllerGetDelete") ."/".$menu->id) }}'
href='javascript:void(0)'></a></span>
<br/><em class="text-muted">
<small><i class="fa fa-users"></i> &nbsp; {{implode(', ',$privileges)}}</small>
Expand All @@ -168,9 +168,9 @@ class='pull-right'><a class='fa fa-pencil' title='Edit'
title="{{$child->is_dashboard?'This is setted as Dashboard':''}}"><i
class='{{($child->is_dashboard)?"icon-is-dashboard fa fa-dashboard":$child->icon}}'></i> {{$child->name}}
<span class='pull-right'><a class='fa fa-pencil' title='Edit'
href='{{route("MenusControllerGetEdit",["id"=>$child->id])}}?return_url={{urlencode(Request::fullUrl())}}'></a>&nbsp;&nbsp;<a
href='{{ route("MenusControllerGetEdit") ."/".$child->id }}?return_url={{urlencode(Request::fullUrl())}}'></a>&nbsp;&nbsp;<a
title="Delete" class='fa fa-trash'
onclick='{{CRUDBooster::deleteConfirm(route("MenusControllerGetDelete",["id"=>$child->id]))}}'
onclick='{{CRUDBooster::deleteConfirm(route("MenusControllerGetDelete") . "/". $child->id) }}'
href='javascript:void(0)'></a></span>
<br/><em class="text-muted">
<small><i class="fa fa-users"></i> &nbsp; {{implode(', ',$privileges)}}</small>
Expand Down

0 comments on commit 98e6f4c

Please sign in to comment.