0

I have User that has many Posts.
Bellow the User edit form I want to show the related Posts grid.

The following function will bring the related posts. How can I combine it above/inside/bellow the edit User form?

I know this function will work, just don't know how to combine it.

// user crud controller

    public function getUserRlatedPosts($user_id)
    {

        $crud = new CrudPanel();
        $crud->addClause('where', 'user_id', '=', $user_id);
        $crud->setModel("post");
        $crud->setEntityNameStrings("post","posts");
        $crud->enableAjaxTable();

        $this->data['crud'] = $crud;
        $this->data['title'] = ucfirst($this->crud->entity_name_plural);
        if (! $this->data['crud']->ajaxTable()) {
            $this->data['entries'] = $this->data['crud']->getEntries();
        }
        return view('crud::list', $this->data);
    }
Cœur
  • 37,241
  • 25
  • 195
  • 267
SexyMF
  • 10,657
  • 33
  • 102
  • 206

1 Answers1

1

In Backpack\CRUD 3.2.x you can use a custom view with the following methods:

$this->crud->setShowView('your-view');
$this->crud->setEditView('your-view');
$this->crud->setCreateView('your-view');
$this->crud->setListView('your-view');
$this->crud->setReorderView('your-view');
$this->crud->setRevisionsView('your-view');
$this->crud->setRevisionsTimelineView('your-view');
$this->crud->setDetailsRowView('your-view');

and specify the view in which you also include that form.

tabacitu
  • 6,047
  • 1
  • 23
  • 37
  • Thanks, I already know that. but I don't understand how can that be achieved? should I move the vendor's views to my views folder and change that? can you provide some explanations? maybe pseudo code? I did not see anything close to that in the docs or in the git issues. thanks again – SexyMF Feb 17 '17 at 15:18
  • Hi Shazam. Nope, just create a /vendor/backpack/crud folder in your /resources/ . That will do it. Then place a single file you want to customize there. – tabacitu Feb 20 '17 at 07:33