Skip to content

Commit 8cfb79d

Browse files
committedJan 31, 2022
Added Blade component x-sortablelink
1 parent 41a4f5c commit 8cfb79d

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
 

‎src/Provider.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Akaunting\Sortable;
44

5+
use Akaunting\Sortable\View\Components\SortableLink;
56
use Illuminate\Support\Facades\Blade;
67
use Illuminate\Support\ServiceProvider;
78

@@ -29,6 +30,7 @@ public function boot()
2930
], 'sortable');
3031

3132
$this->registerBladeDirectives();
33+
$this->registerBladeComponents();
3234
$this->registerMacros();
3335
}
3436

@@ -41,6 +43,11 @@ public function registerBladeDirectives()
4143
});
4244
}
4345

46+
public function registerBladeComponents()
47+
{
48+
Blade::component('sortablelink', SortableLink::class);
49+
}
50+
4451
public function registerMacros()
4552
{
4653
request()->macro('allFilled', function (array $keys) {

‎src/View/Components/SortableLink.php

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Akaunting\Sortable\View\Components;
4+
5+
use Akaunting\Sortable\Support\SortableLink as Base;
6+
use Illuminate\View\Component;
7+
8+
class SortableLink extends Component
9+
{
10+
/**
11+
* The sortablelink column.
12+
*
13+
* @var string
14+
*/
15+
public $column;
16+
17+
/**
18+
* The sortablelink title.
19+
*
20+
* @var string
21+
*/
22+
public $title;
23+
24+
/**
25+
* The sortablelink query.
26+
*
27+
* @var array
28+
*/
29+
public $query;
30+
31+
/**
32+
* The sortablelink arguments.
33+
*
34+
* @var array
35+
*/
36+
public $arguments;
37+
38+
/**
39+
* Create the component instance.
40+
*
41+
* @param string $title
42+
* @param string $column
43+
* @param array $parameters
44+
* @param array $attribute
45+
* @return void
46+
*/
47+
public function __construct($column, $title, $query = [], $arguments = [])
48+
{
49+
$this->column = $column;
50+
$this->title = $title;
51+
$this->query = $query;
52+
$this->arguments = $arguments;
53+
}
54+
55+
/**
56+
* Get the view / contents that represent the component.
57+
*
58+
* @return \Illuminate\View\View|\Closure|string
59+
*/
60+
public function render()
61+
{
62+
return Base::render([
63+
$this->column,
64+
$this->title,
65+
$this->query,
66+
$this->arguments,
67+
]);
68+
}
69+
}

0 commit comments

Comments
 (0)
Please sign in to comment.