Skip to content

Commit 714583f

Browse files
authored
add chips examples (#701)
1 parent de2d05e commit 714583f

File tree

6 files changed

+353
-24
lines changed

6 files changed

+353
-24
lines changed

app/Http/Controllers/Admin/PetShop/InvoiceCrudController.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Http\Requests\InvoiceRequest;
66
use Backpack\CRUD\app\Http\Controllers\CrudController;
77
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
8+
use Backpack\CRUD\app\Library\Widget;
89

910
/**
1011
* Class InvoiceCrudController.
@@ -53,15 +54,10 @@ public function setupLast5YearsView()
5354
protected function setupListOperation()
5455
{
5556
CRUD::addColumn([
56-
'name' => 'owner',
57-
'label' => 'Owner',
58-
'linkTo' => [
59-
'route' => 'owner.show',
60-
'target' => '_blank',
61-
],
57+
'name' => 'info',
58+
'type' => 'view',
59+
'view' => 'crud::chips.invoice',
6260
]);
63-
CRUD::column('series');
64-
CRUD::column('number');
6561
CRUD::column('issuance_date');
6662
CRUD::column('due_date');
6763
CRUD::column('total');
@@ -148,6 +144,17 @@ protected function setupShowOperation()
148144
$this->autoSetupShowOperation();
149145

150146
CRUD::column('total');
147+
148+
// get the owner with important relationships
149+
$owner = CRUD::getCurrentEntry()->owner()->with('avatar', 'invoices')->first();
150+
151+
// add a chip widget for the owner
152+
Widget::add()
153+
->to('after_content')
154+
->type('chip')
155+
->view('crud::chips.owner')
156+
->title('Owner')
157+
->entry($owner);
151158
}
152159

153160
public function fetchOwner()

composer.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/views/admin/new-in-v7.blade.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@
3333

3434
@section('content')
3535

36+
<!-- Heading for chips -->
37+
<div class="row g-2 align-items-center mt-3">
38+
<div class="col">
39+
<div class="page-pretitle">Views</div>
40+
<h2 class="page-title">Chips</h2>
41+
<p class="mt-2 mb-2">Include more information about an Eloquent model, in a small space. Hover over the headings
42+
to understand more about the examples.</p>
43+
</div>
44+
<div class="col-auto ms-auto d-print-none">
45+
<div class="btn-list">
46+
<span class="d-none d-sm-inline">
47+
<a href="#" class="btn btn-primary"> See docs </a> <!-- TODO: link to final docs -->
48+
</span>
49+
</div>
50+
</div>
51+
</div>
52+
53+
@include('admin.partials.chip-examples')
54+
3655
<!-- Heading for Datagrid component -->
3756
<div class="row g-2 align-items-center">
3857
<div class="col @if(session('backpack.theme-tabler.layout') == 'horizontal_overlap') text-white @endif">
@@ -103,6 +122,7 @@
103122
</div>
104123
</div>
105124

125+
106126
@include('admin.partials.dataform-examples')
107127

108128
@endsection

0 commit comments

Comments
 (0)