Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Admin\Agen;
- 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\PerusahaanRequest as StoreRequest;
- use App\Http\Requests\PerusahaanRequest as UpdateRequest;
- class AgenKerjasamaController extends CrudController{
- public function setup()
- {
- /*
- |--------------------------------------------------------------------------
- | CrudPanel Basic Information
- |--------------------------------------------------------------------------
- */
- $this->crud->setModel('App\Models\Agent_kerjasama');
- $this->crud->setRoute(config('backpack.base.route_prefix') . '/agen/kerjasama');
- $this->crud->setEntityNameStrings('Agent Cabang', 'Agent Cabang');
- /*
- |--------------------------------------------------------------------------
- | CrudPanel Configuration
- |--------------------------------------------------------------------------
- */
- $this->crud->addColumn([
- 'type' => 'text',
- 'name' => 'nama_perusahaan' ,
- 'label' => 'Nama Agent'
- ]);
- $this->crud->addColumn([
- 'type' => 'text',
- 'name' => 'no_telp',
- 'label' => 'Kontak'
- ]);
- $this->crud->addColumn([
- 'type' => 'text',
- 'name' => 'nama_pimpinan',
- 'label' => 'Nama Pimpinan'
- ]);
- $this->crud->addColumn([
- 'name' => 'status_perusahaan',
- 'label' => 'Status Perusahaan',
- 'type' => 'select_from_array',
- 'options' => [
- '0' => 'Draft',
- '1' => 'Aktif',
- '2' => 'Tidak Aktif'
- ],
- 'tab' => 'Status'
- ]);
- $this->crud->addColumn([
- 'name' => 'agen_type',
- 'label' => 'Tipe Agent',
- 'type' => 'select_from_array',
- 'options' => [
- '1' => 'Alfa',
- '2' => 'Izin',
- '3' => 'Kerjasama'
- ],
- 'tab' => 'Status'
- ]);
- //============OTHER CONFIG
- $this->crud->removeAllButtons();
- $this->crud->addField([
- 'type' => 'hidden',
- 'name' => 'token',
- 'label' => 'Hidden',
- 'value' => strtoupper(substr(uniqid(), 0, 6))
- ]);
- if(isset(backpack_user()->user_perusahaan->perusahaan->id)){
- $this->crud->addField([
- 'type' => 'hidden',
- 'name' => 'parent_id',
- 'label' => 'Parent ID',
- 'value' => backpack_user()->user_perusahaan->perusahaan->id,
- ]);
- }
- $this->crud->addButtonFromModelFunction('line', 'show_agent_detail', 'showAgentDetail', 'beginning'); // add a button whose HTML is returned by a method in the CRUD model
- $this->crud->allowAccess('show');
- // add asterisk for fields that are required in PerusahaanRequest
- $this->crud->setRequiredFields(StoreRequest::class, 'create');
- $this->crud->setRequiredFields(UpdateRequest::class, 'edit');
- }
- public function store(StoreRequest $request)
- {
- // your additional operations before save here
- $redirect_location = parent::storeCrud($request);
- // your additional operations after save here
- // use $this->data['entry'] or $this->crud->entry
- return $redirect_location;
- }
- public function update(UpdateRequest $request)
- {
- // your additional operations before save here
- $redirect_location = parent::updateCrud($request);
- // your additional operations after save here
- // use $this->data['entry'] or $this->crud->entry
- return $redirect_location;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment