Наследование: extends Illuminate\Database\Eloquent\Model
 /**
  * Show the form for editing the specified sitesplugins.
  *
  * @param  int  $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $sitesplugins = Sitesplugins::find($id);
     $menu = Menu::orderby('position')->lists('title', 'id');
     $sites = Sites::lists('title', 'id');
     return view('admin.sitesplugins.edit', compact('sitesplugins', 'menu', 'sites'));
 }
 /**
  * @param $request
  *
  * @return array
  */
 private function parseData($request)
 {
     $role = $request->user()->role_id;
     $route = explode('.', $request->route()->getName());
     $official = ['menu', 'users', 'actions'];
     if (in_array($route[0], $official)) {
         return [$role, (object) ['roles' => config('quickadmin.defaultRole') . ',']];
     } else {
         $menuName = $route[1];
     }
     $menu = Menu::where('name', ucfirst($menuName))->firstOrFail();
     return [$role, $menu];
 }
Пример #3
0
 /**
  * Build relationships for forms
  * @return string
  */
 public function relationshipsBuilder()
 {
     if ($this->relationships == 0) {
         return '';
     } else {
         $menus = Menu::all()->keyBy('id');
         $relationships = '';
         $first = true;
         foreach ($this->fields as $field) {
             if ($field->type == 'relationship') {
                 // Formatting fix if the relationship is not first
                 if (!$first) {
                     $relationships .= '        ';
                 }
                 $menu = $menus[$field->relationship_id];
                 $relationships .= '$' . $field->relationship_name . ' = ' . ucfirst(Str::camel($menu->name)) . '::lists("' . $field->relationship_field . '", "id");' . "\r\n";
             }
         }
         return $relationships;
     }
 }
 public function update(Request $request, $id)
 {
     $roles = Role::all();
     $rolesInsert = '';
     $first = true;
     foreach ($roles as $role) {
         if ($request->{'role-' . $role->id} == 1) {
             if ($first != true) {
                 $rolesInsert .= ',';
             }
             $rolesInsert .= $role->id;
             $first = false;
         }
     }
     $requestArray = $request->all();
     if ($requestArray['parent_id'] === "null") {
         $requestArray['parent_id'] = null;
     }
     $requestArray['roles'] = $rolesInsert;
     $menu = Menu::findOrFail($id);
     $menu->update($requestArray);
     return redirect()->route('menu');
 }
Пример #5
0
<?php

/**
 * Package routing file specifies all of this package routes.
 */
use Illuminate\Support\Facades\View;
use Laraveldaily\Quickadmin\Models\Menu;
if (Schema::hasTable('menus')) {
    $menus = Menu::with('children')->where('menu_type', '!=', 0)->orderBy('position')->get();
    View::share('menus', $menus);
    if (!empty($menus)) {
        Route::group(['middleware' => ['web', 'auth', 'role'], 'prefix' => config('quickadmin.route'), 'namespace' => 'App\\Http\\Controllers'], function () use($menus) {
            foreach ($menus as $menu) {
                switch ($menu->menu_type) {
                    case 1:
                        Route::post(strtolower($menu->name) . '/massDelete', ['as' => config('quickadmin.route') . '.' . strtolower($menu->name) . '.massDelete', 'uses' => 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller@massDelete']);
                        Route::resource(strtolower($menu->name), 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller');
                        break;
                    case 3:
                        Route::controller(strtolower($menu->name), 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller', ['getIndex' => config('quickadmin.route') . '.' . strtolower($menu->name) . '.index']);
                        break;
                }
            }
        });
    }
}
Route::group(['namespace' => 'Laraveldaily\\Quickadmin\\Controllers', 'middleware' => ['web', 'auth']], function () {
    // Dashboard home page route
    Route::get(config('quickadmin.homeRoute'), 'QuickadminController@index');
    Route::group(['middleware' => 'role'], function () {
        // Menu routing
Пример #6
0
 /**
  * Build model relationships
  * @return string
  */
 private function buildRelationships()
 {
     $menus = Menu::all()->keyBy('id');
     $used = [];
     $relationships = '';
     foreach ($this->fields as $key => $field) {
         if (!in_array($field->title, $used) && $field->type == 'relationship') {
             $menu = $menus[$field->relationship_id];
             $relLine = '
 public function $RELATIONSHIP$()
 {
     return $this->hasOne(\'App\\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
 }' . "\r\n\r\n";
             $relLine = str_replace(['$RELATIONSHIP$', '$RELATIONSHIP_MODEL$'], [strtolower($menu->name), ucfirst(Str::camel($menu->name))], $relLine);
             $relationships .= $relLine;
         }
     }
     return $relationships;
 }
 /**
  *  Copy master template to resource/view
  */
 public function copyMasterTemplate()
 {
     Menu::create(['name' => 'User', 'title' => 'User', 'menu_type' => 0]);
     $this->callSilent('vendor:publish', ['--tag' => ['quickadmin'], '--force' => true]);
     $this->info('Master template was transferred successfully');
 }
 public function update(Request $request, $id)
 {
     $menu = Menu::findOrFail($id);
     $menu->update($request->all());
     return redirect()->route('menu');
 }
Пример #9
0
<?php

/**
 * Package routing file specifies all of this package routes.
 */
use Illuminate\Support\Facades\View;
use Laraveldaily\Quickadmin\Models\Menu;
/*
* Amir's custom code
* ->leftJoin('sitesplugins', 'menus.id', '=', 'sitesplugins.menu_id')
*/
if (Schema::hasTable('menus')) {
    $menus = Menu::with('children')->where('menu_type', '!=', 0)->leftJoin('sitesplugins', 'menus.id', '=', 'sitesplugins.menu_id')->select(DB::raw('GROUP_CONCAT(sitesplugins.sites_id) as   sites_id'), 'menus.*')->groupBy('menus.id')->orderBy('position')->get();
    View::share('menus', $menus);
    if (!empty($menus)) {
        Route::group(['middleware' => ['web', 'auth', 'role'], 'prefix' => config('quickadmin.route'), 'namespace' => 'App\\Http\\Controllers'], function () use($menus) {
            foreach ($menus as $menu) {
                switch ($menu->menu_type) {
                    case 1:
                        Route::post(strtolower($menu->name) . '/massDelete', ['as' => config('quickadmin.route') . '.' . strtolower($menu->name) . '.massDelete', 'uses' => 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller@massDelete']);
                        Route::resource(strtolower($menu->name), 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller');
                        break;
                    case 3:
                        Route::controller(strtolower($menu->name), 'Admin\\' . ucfirst(camel_case($menu->name)) . 'Controller', ['getIndex' => config('quickadmin.route') . '.' . strtolower($menu->name) . '.index']);
                        break;
                }
            }
        });
    }
}
Route::group(['namespace' => 'Laraveldaily\\Quickadmin\\Controllers', 'middleware' => ['web', 'auth']], function () {
 public function update(Request $request, $id)
 {
     $requestArray = $request->all();
     $requestArray['parent_id'] = isset($requestArray['parent_id']) && !empty($requestArray['parent_id']) ? $requestArray['parent_id'] : null;
     $menu = Menu::findOrFail($id);
     $menu->update($requestArray);
     $menu->roles()->sync($request->input('roles', []));
     return redirect()->route('menu');
 }