mau bertanya,di forum ini ada kah yang menggunakan backpack laravel?

saya mau bertanya tentang inline di backpack laravel, sebenarnya tampilan modal sudah muncul dan bisa di simpan.hanya saja untuk search data yang sudah ada itu tidak muncul, mohon infonya.

ini Models saya

<?php
namespace App\Models;

use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;

class Stoks extends Model
{
    use CrudTrait;

    /*
    |--------------------------------------------------------------------------
    | GLOBAL VARIABLES
    |--------------------------------------------------------------------------
    */
    protected $connection='mysql';
    protected $table = 'stok';
    // protected $primaryKey = 'id';
    // public $timestamps = false;
    protected $guarded = ['id'];
    // protected $fillable = [];
    // protected $hidden = [];
    // protected $dates = [];

    /*
    |--------------------------------------------------------------------------
    | FUNCTIONS
    |--------------------------------------------------------------------------
    */

    /*
    |--------------------------------------------------------------------------
    | RELATIONS
    |--------------------------------------------------------------------------
    */
    public function jenisbarang()
    {
        return $this->belongsTo('App\Models\Jenisbarang','id_jenis_barang','id');
    }

    /*
    |--------------------------------------------------------------------------
    | SCOPES
    |--------------------------------------------------------------------------
    */

    /*
    |--------------------------------------------------------------------------
    | ACCESSORS
    |--------------------------------------------------------------------------
    */

    /*
    |--------------------------------------------------------------------------
    | MUTATORS
    |--------------------------------------------------------------------------
    */
}

ini Controllernya

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests\StoksRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;

/**
 * Class StoksCrudController
 * @package App\Http\Controllers\Admin
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
 */
class StoksCrudController extends CrudController
{
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;

    /**
     * Configure the CrudPanel object. Apply settings to all operations.
     *
     * @return void
     */
    public function setup()
    {
        CRUD::setModel(\App\Models\Stoks::class);
        CRUD::setRoute(config('backpack.base.route_prefix') . '/stoks');
        CRUD::setEntityNameStrings('stok', 'stok');
    }

    /**
     * Define what happens when the List operation is loaded.
     *
     * @see  https://backpackforlaravel.com/docs/crud-operation-list-entries
     * @return void
     */
    protected function setupListOperation()
    {

        CRUD::column('kodeBarang');
        CRUD::column('namaBarang');
        CRUD::column('id_jenis_barang')
            ->type('select')
            ->entity('jenisbarang')
            ->model('App\Models\jenisbarang')
            ->attribute('jenis')
            ->label('Jenis Barang');
        CRUD::column('hargaJual');
        CRUD::column('discount');
        CRUD::column('stock');

        /**
         * Columns can be defined using the fluent syntax or array syntax:
         * - CRUD::column('price')->type('number');
         * - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
         */
    }

    /**
     * Define what happens when the Create operation is loaded.
     *
     * @see https://backpackforlaravel.com/docs/crud-operation-create
     * @return void
     */
    protected function setupCreateOperation()
    {
        CRUD::setValidation(StoksRequest::class);

        //CRUD::field('id');
        CRUD::field('kodeBarang')->label('Kode Barang');
        CRUD::field('namaBarang')->label('Nama Barang');
        CRUD::field('jenisbarang')
            ->type('relationship')
            ->placeholder('pilih Jenis Barang Anda')
            ->attribute('jenis')
            ->entity('jenisbarang')
            ->model('App\Models\jenisbarang')
            ->inline_create(true)
            ->ajax(true)
            ->label('Jenis Barang');
        CRUD::field('hargaJual')->default(0);
        CRUD::field('discount')->default(0);

        /**
         * Fields can be defined using the fluent syntax or array syntax:
         * - CRUD::field('price')->type('number');
         * - CRUD::addField(['name' => 'price', 'type' => 'number']));
         */
    }

    /**
     * Define what happens when the Update operation is loaded.
     *
     * @see https://backpackforlaravel.com/docs/crud-operation-update
     * @return void
     */
    protected function setupUpdateOperation()
    {
        $this->setupCreateOperation();
    }
}

terimkash sebelumnya...

avatar achmadfaliqulisbah
@achmadfaliqulisbah

1 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Tanggapan

bikin judul pertanyaan sesuai yang kamu tanyakan ya

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban