Skip to content

Commit

Permalink
Merge pull request #396 from RezaAb/master
Browse files Browse the repository at this point in the history
fix some bugs
  • Loading branch information
AlirezaAlgo authored Jun 20, 2019
2 parents f780155 + fd47b86 commit 8396248
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/Serverfireteam/Panel/Commands/PanelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public function handle()

$this->info('** publishing panel assets');
$this->call('vendor:publish', [
'--tag' => 'public',
'--tag' => 'panelpublic',
'--quiet' => null
//'--force' => 1
]);
$this->info('** publishing panel config');
$this->call('vendor:publish', [
'--tag' => 'config',
'--tag' => 'panelconfig',
'--quiet' => null
//'--force' => 1
]);
$this->info('** publishing panel views');
$this->call('vendor:publish', [
'--tag' => 'views',
'--tag' => 'panelviews',
'--quiet' => null
//'--force' => 1
]);
Expand Down
6 changes: 3 additions & 3 deletions src/Serverfireteam/Panel/PanelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ public function register()

$this->publishes([
__DIR__ . '/../../../public' => public_path('packages/serverfireteam/panel')
], 'public');
], 'panelpublic');

$this->publishes([
__DIR__.'/config/panel.php' => config_path('panel.php'),
__DIR__.'/config/elfinder.php' => config_path('elfinder.php'),
], 'config');
], 'panelconfig');
}

public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../views', 'panelViews');
$this->publishes([
__DIR__.'/../../views' => base_path('resources/views/vendor/panelViews'),
], 'views');
], 'panelviews');

include __DIR__."/../../routes.php";

Expand Down
63 changes: 43 additions & 20 deletions src/controllers/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,62 @@

use \Serverfireteam\Panel\libs\PanelElements;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Request;

class MainController extends Controller {


public function entityUrl($entity, $methods){
$uri = Request::path();
// Get route collection
$routes = collect(Route::getRoutes()->getRoutes())->reduce(function ($carry = [], $route) {
starts_with($route->uri(), 'panel/{entity}') ?: $carry[] = $route;

return $carry;
});
try {
// If we find a match, take the user there.
foreach ($routes as $route){
if ($uri == $route->uri()){
$controller_path = $route->getAction()['controller'];
$controller_action = explode('@',$controller_path);
$controller = \App::make($controller_action[0]);
return $controller->callAction($controller_action[1], array());
break;
}
}
}
catch (Exception $e){
// Otherwise, we didn't find a match so take the user to the admin page.
return redirect('/panel');
}

$appHelper = new libs\AppHelper();
$appHelper = new libs\AppHelper();

if ( \Links::isMain($entity)){
$controller_path = 'Serverfireteam\Panel\\'.$entity.'Controller';
} else {
} else {
$panel_path = \Config::get('panel.controllers');
if ( isset($panel_path) ){
$controller_path = '\\'.$panel_path.'\\'.$entity.'Controller';
} else {
$controller_path = $appHelper->getNameSpace().'Http\Controllers\\'.$entity.'Controller';
}
}

try{
$controller = \App::make($controller_path);
}catch(\Exception $ex){
throw new \Exception("Controller not found ( $controller_path ) ");
}
if ( isset($panel_path) ){
$controller_path = '\\'.$panel_path.'\\'.$entity.'Controller';
} else {
$controller_path = $appHelper->getNameSpace().'Http\Controllers\\'.$entity.'Controller';
}
}

try{
$controller = \App::make($controller_path);
}catch(\Exception $ex){
throw new \Exception("Controller not found ( $controller_path ) ");
}
if (!method_exists($controller, $methods)){
throw new \Exception('Controller does not implement the CrudController methods!');
} else {
return $controller->callAction($methods, array('entity' => $entity));
}

if (!method_exists($controller, $methods)){
throw new \Exception('Controller does not implement the CrudController methods!');
} else {
return $controller->callAction($methods, array('entity' => $entity));
}

}
}


0 comments on commit 8396248

Please sign in to comment.