Monday, May 22, 2017

Integrate custom view in laravel's backpack crud

I want to integrate a custom view to be able to use the Crud package Api, for example, $this->crud->enableExportButtons();

In ReportCrudController every function use different Models, each function is called through custom routes. but the Crud Api is not available.

my controller:

<?php

namespace App\Http\Controllers\Admin;

 use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\TagCrudRequest as StoreRequest;
use App\Http\Requests\TagCrudRequest as UpdateRequest;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Estacion;
use App\Importacion;
use App\Equipo;
use App\Parametro;
use App\InventarioParametro;

class ReportesCrudController extends CrudController
{
  public function setup(){
    $this->crud->setModel("App\Importacion");
    $this->crud->setRoute("admin/listado_importacion");
    $this->crud->setEntityNameStrings('importacion', 'importaciones');
    $this->crud->enableExportButtons();  <--- Api function
  }
  public function listado_parametro_estacion(){

     $result =  InventarioParametro::paginate(10); 
     // dd($result);
     return view('reportes.listado_estacion_equipo',compact('result'));
  } 

  public function listado_importacion(){

    // $this->crud->setModel("App\Importacion");
    // $this->crud->setRoute("admin/listado_importacion");
    // $this->crud->setEntityNameStrings('importacion', 'importaciones');
    // $this->crud->enableExportButtons();

      $this->crud->setColumns(['id','nombre_documento','responsable','created_at']);
     // $this->crud->enableAjaxTable();
    $importaciones = Importacion::orderBy('id','DES')->paginate(10);
    return view('reportes.listado_importacion',compact('importaciones'));  
  }

  public function listado_equipo_parametro(Request $request){

   $eq_parametro = Equipo::with('parametros')->with('estaciones')
                  ->buscarparametro($request->get('parametros'))
                  ->paginate(10);

     //dd($eq_parametro);           
   $parametros = Parametro::pluck('nombre','id')->toArray(); 
   return view('reportes.listado_equipo_parametro', compact('parametros','eq_parametro'));

 }

}

custom view

it should show a bar with export buttons over the list.



via Rodrigo Rose

Advertisement