-1

I want to make the list of table who have relation only, example:

Table:

  • Order
  • Process

In ProcessCrudController I want to replace the Process list view into Order list view that only have relation (order-process).

The solution I've tried:

  • Create new function in OrderCrudController return view($this->crud->getListView(), $this->data);
  • then, addClause using $request->type URL

The problem of that solution:

  • Not showing the action row in table
  • Easy to show all query if we try to remove URL

I really want to make the list view of Process that only already have relation to Order, or any suggestion/idea to make this happen?

NB: I'm struggling at this problem I didn't found the solution, help me please

EDIT (Adding Code):

OrderCrudController:

protected function setupListOperation()
{

    // This is the solution that I described before
    // $request = request();
    // $this->crud->addClause('where', 'user_id', '=', $request->type ?? 1);

    $this->crud->addColumns([
        [
            'name' => 'personal_name',
            'label' => 'Name',
            'type'  => 'text',
        ],
        [
            'name' => 'notes',
            'label' => 'Catatan',
            'type'  => 'textarea',
        ],
        [
            'name'  => 'user_id',
            'label' => 'Dibuat oleh',
            'type'  => 'select',
            'entity' => 'user',
            'attribute' => 'name',
            'model' => 'App\User',
        ],
    ]);
}

ProcessCrudController:

protected function setupListOperation()
{
    CRUD::setFromDb();
    
    // This table should be listing Order's query and that only have a process (already created custom_create_view)
    // That's why i want to take Order's table and not making new custom_list_view
}
vreedom18
  • 341
  • 2
  • 13

1 Answers1

0

you don't have to make a new view, you just modify the query result using addClause ....

in your ProcessCrudController in setupListOperation() add your clause:

 $this->crud->addClause('has','order');

assuming that the relation name in Process model that point to Process is "order"

OMR
  • 11,736
  • 5
  • 20
  • 35
  • I want to show OrderList in ProcessCrudController that only have a process, not showing the ProcessList – vreedom18 Jul 23 '20 at 07:51