Skip to content

Commit 8fc9608

Browse files
committed
add sortable function
1 parent e7d6cfe commit 8fc9608

File tree

6 files changed

+83
-11
lines changed

6 files changed

+83
-11
lines changed

app/Http/Controllers/SpecificationsController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SpecificationsController extends Controller
1010
public function __invoke()
1111
{
1212
return view('specifications', [
13-
'specifications' => Specification::all()
13+
'specifications' => Specification::sortable()->paginate(100)
1414
]);
1515
}
1616
}

app/Specification.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
namespace App;
44

5+
use Kyslik\ColumnSortable\Sortable;
56
use Illuminate\Database\Eloquent\Model;
67

78
class Specification extends Model
89
{
9-
//
10+
use Sortable;
11+
12+
public $sortable = [
13+
'model',
14+
'ver',
15+
'num',
16+
'manufacturer',
17+
'vender_id',
18+
'year',
19+
'week',
20+
];
1021
}

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"require": {
1111
"php": "^7.2",
1212
"fideloper/proxy": "^4.0",
13+
"kyslik/column-sortable": "^6.2",
1314
"laravel/framework": "^6.2",
1415
"laravel/tinker": "^2.0"
1516
},

composer.lock

+58-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/views/layouts/app.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- CSRF Token -->
88
<meta name="csrf-token" content="{{ csrf_token() }}">
99

10-
<title>{{ config('app.name', 'EDID') }}</title>
10+
<title>EDID</title>
1111

1212
<!-- Scripts -->
1313
<script src="{{ asset('js/app.js') }}" defer></script>

resources/views/specifications.blade.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<table class="table table-striped">
1212
<thead class="thead-dark">
1313
<tr>
14-
<th>Model name</th>
15-
<th>Ver</th>
16-
<th>Num</th>
17-
<th>Manufacturer</th>
18-
<th>VenderId</th>
19-
<th>Year</th>
20-
<th>Week</th>
14+
<th>@sortablelink('model', 'Model name')</th>
15+
<th>@sortablelink('ver', 'Ver')</th>
16+
<th>@sortablelink('num', 'Num')</th>
17+
<th>@sortablelink('manufacturer', 'Manufacturer')</th>
18+
<th>@sortablelink('vender_id', 'VenderId')</th>
19+
<th>@sortablelink('year', 'Year')</th>
20+
<th>@sortablelink('week', 'Week')</th>
2121
</tr>
2222
</thead>
2323
<tbody>
@@ -34,6 +34,9 @@
3434
@endforeach
3535
</tbody>
3636
</table>
37+
<div class="pagination pagination-centered">
38+
{{ $specifications->links() }}
39+
</div>
3740
</div>
3841
</div>
3942
</div>

0 commit comments

Comments
 (0)