コード例 #1
0
 /**
  * get theme breadcrumb
  *
  * @param array $models
  * @param array $columns
  * @return  string
  */
 public function getBreadcrumb($models = [], $columns = [])
 {
     $transAndRoute = $this->getTransRouteParam($models, $columns);
     $modelTrans = $transAndRoute['trans'];
     $modelRoute = $transAndRoute['route'];
     $breadcrumbs = '<ul class="page-breadcrumb breadcrumb">';
     // admin dashboard
     if (!is_null(app()->getProvider(config('laravel-modules-core.packages.laravel-dashboard-module')))) {
         $breadcrumbs .= $this->getDashboardBreadcrumb();
     }
     // if admin dashboard index return
     if (strpos($this->route_name, 'dashboard') !== false) {
         $breadcrumbs .= '</ul>';
         return $breadcrumbs;
     }
     $breadcrumbs .= '<li>';
     $parent_text = strpos($this->route_name, 'index') !== false ? trans($this->module_name . $this->route_name, $modelTrans) : trans($this->module_name . $this->index_route_name, $modelTrans);
     if (strpos($this->route_name, 'index') !== false) {
         $breadcrumbs .= $parent_text;
     } else {
         if (Route::has($this->index_route_name)) {
             $hackedRoute = isset($modelRoute['id']) && routeHackable($this->index_route_name) ? $this->index_route_name . '#####' . $modelRoute['id'] : $this->index_route_name;
             $route = hasPermission($hackedRoute) ? lmbRoute($this->index_route_name, $modelRoute) : 'javascript:;';
             $breadcrumbs .= '<a href="' . $route . '">' . $parent_text . '</a><i class="fa fa-circle"></i>';
         }
     }
     $breadcrumbs .= '</li>';
     if (strpos($this->route_name, 'index') === false) {
         $breadcrumbs .= '<li> <span class="active"> ' . trans($this->module_name . $this->route_name, $modelTrans) . '</span> </li>';
     }
     $breadcrumbs .= '</ul>';
     return $breadcrumbs;
 }
コード例 #2
0
 /**
  * get operation buttons
  *
  * @param \Illuminate\Support\Collection $model
  * @param string $currentPage
  * @param boolean $isPublishable
  * @param \Illuminate\Support\Collection|null $relatedModel
  * @param string $modelRouteRegex
  * @return string
  */
 function getOps($model, $currentPage, $isPublishable = false, $relatedModel = null, $modelRouteRegex = '')
 {
     $routeName = snake_case(class_basename($model));
     $routeParams = ['id' => $model->id];
     if (!is_null($relatedModel)) {
         $routeName = snake_case(class_basename($relatedModel)) . '.' . $routeName;
         $routeParams = ['id' => $relatedModel->id, $modelRouteRegex => $model->id];
     }
     $ops = Form::open(['method' => 'DELETE', 'url' => lmbRoute("admin.{$routeName}.destroy", $routeParams), 'style' => 'margin:0', 'id' => "destroy_form_{$model->id}"]);
     // edit buton
     if ($currentPage !== 'edit') {
         $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.show") ? "admin.{$routeName}.show#####" . $relatedModel->id : "admin.{$routeName}.edit";
         if ($routeName === 'user' && $model->id === Sentinel::getUser()->id || hasPermission($hackedRoute)) {
             $ops .= '<a href="' . lmbRoute("admin.{$routeName}.edit", $routeParams) . '" class="btn btn-sm btn-outline yellow margin-right-10">';
             $ops .= '<i class="fa fa-pencil"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.edit');
             $ops .= '</span>';
             $ops .= '</a>';
         }
     }
     // show buton
     if ($currentPage !== 'show') {
         $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.show") ? "admin.{$routeName}.show#####" . $relatedModel->id : "admin.{$routeName}.show";
         if ($routeName === 'user' && $model->id === Sentinel::getUser()->id || hasPermission($hackedRoute)) {
             $ops .= '<a href="' . lmbRoute("admin.{$routeName}.show", $routeParams) . '" class="btn btn-sm btn-outline green margin-right-10">';
             $ops .= '<i class="fa fa-search"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.show');
             $ops .= '</span>';
             $ops .= '</a>';
         }
     }
     // silme butonu
     $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.destroy") ? "admin.{$routeName}.destroy#####" . $relatedModel->id : "admin.{$routeName}.destroy";
     if (hasPermission($hackedRoute)) {
         if ($routeName !== 'user' || $model->id !== Sentinel::getUser()->id) {
             $ops .= '<button type="submit" onclick="bootbox.confirm( \'' . trans('laravel-modules-core::admin.ops.destroy_confirmation') . '\', function(r){if(r) $(\'#destroy_form_' . $model->id . '\').submit();}); return false;" class="btn btn-sm red btn-outline margin-right-10">';
             $ops .= '<i class="fa fa-trash"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.destroy');
             $ops .= '</span>';
             $ops .= '</button>';
         }
     }
     // yayınlama veya yayından kaldırma butonu
     if ($isPublishable) {
         // yayından kaldırma
         if ($model->is_publish) {
             $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.notPublish") ? "admin.{$routeName}.notPublish#####" . $relatedModel->id : "admin.{$routeName}.notPublish";
             if (hasPermission($hackedRoute)) {
                 $ops .= '<a href="' . lmbRoute("admin.{$routeName}.notPublish", $routeParams) . '" class="btn btn-sm btn-outline purple margin-right-10">';
                 $ops .= '<i class="fa fa-times"></i>';
                 $ops .= '<span class="hidden-xs">';
                 $ops .= trans('laravel-modules-core::admin.ops.not_publish');
                 $ops .= '</span>';
                 $ops .= '</a>';
             }
         } else {
             $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.publish") ? "admin.{$routeName}.publish#####" . $relatedModel->id : "admin.{$routeName}.publish";
             if (hasPermission($hackedRoute)) {
                 $ops .= '<a href="' . lmbRoute("admin.{$routeName}.publish", $routeParams) . '" class="btn btn-sm btn-outline blue margin-right-10">';
                 $ops .= '<i class="fa fa-bullhorn"></i>';
                 $ops .= '<span class="hidden-xs">';
                 $ops .= trans('laravel-modules-core::admin.ops.publish');
                 $ops .= '</span>';
                 $ops .= '</a>';
             }
         }
     }
     $ops .= Form::close();
     return $ops;
 }
コード例 #3
0
 /**
  * Generate a URL to a named route.
  *
  * @param  string  $name
  * @param  array   $parameters
  * @return string
  */
 function routeHack($name, $parameters = [])
 {
     if (is_null($name) || !routeHackable($name)) {
         return $name;
     }
     $hacked = $name;
     if (count($parameters) > 0) {
         $hacked .= '#####' . $parameters['id'];
     }
     return $hacked;
 }