Skip to content

Commit 9563a12

Browse files
add TrixField
add Filters and some small improvments
1 parent 6ea5c50 commit 9563a12

File tree

21 files changed

+46170
-136
lines changed

21 files changed

+46170
-136
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@
1010
You can install the package via composer:
1111

1212
```bash
13-
composer require max-hutschenreiter/the-laravel-admin-panel
13+
composer require the42coders/the-laravel-admin-panel
1414
```
1515

1616
You need to register the routes to your web.php routes File as well. Since the-laravel-admin-panel Package is very powerful make sure to secure the routes with whatever authentication you use in the rest of your app.
1717

1818
```php
1919
Route::group(['middleware' => ['auth']], function () {
20-
\the42coders\Workflows\Workflows::routes();
20+
\the42coders\TLAP\TLAP::routes();
2121
});
2222
```
2323

2424
You need to publish the assets of the Package
2525

2626
```bash
27-
php artisan vendor:publish --provider="the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=assets
27+
php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=assets
2828
```
2929

3030
Other publishable Contents are
3131

3232
config
3333

3434
```bash
35-
php artisan vendor:publish --provider="the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=config
35+
php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=config
3636
```
3737

3838
language
3939

4040
```bash
41-
php artisan vendor:publish --provider="the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=lang
41+
php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=lang
4242
```
4343

4444
views
4545

4646
```bash
47-
php artisan vendor:publish --provider="the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=views
47+
php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=views
4848
```
4949

5050

@@ -72,7 +72,7 @@ Now you can just visit the url of https://your-website.de/admin.
7272
You can change the url under which the admin panel will be accessible
7373
in the tlap.php config file with the path variable.
7474

75-
This package autoloads your relations if you use return types on them.
75+
This package autoload your relations if you use return types on them.
7676

7777
``` php
7878
public function posts(): HasMany

config/config.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/*
44
* You can place your custom package configuration in here.
55
*/
6+
67
return [
78

89
/*
@@ -30,4 +31,54 @@
3031
//'companies' => 'App\Models\Company',
3132
],
3233

34+
/*
35+
|--------------------------------------------------------------------------
36+
| Relations
37+
|--------------------------------------------------------------------------
38+
|
39+
| Define an array of Relation return types which will be automatically resolved in the show and edit view.
40+
|
41+
*/
42+
43+
'relations' => [
44+
'HasOne',
45+
'HasMany',
46+
'BelongsTo',
47+
'BelongsToMany',
48+
'MorphToMany',
49+
'MorphTo'
50+
],
51+
52+
/*
53+
|--------------------------------------------------------------------------
54+
| Auto Field discovery
55+
|--------------------------------------------------------------------------
56+
|
57+
| Define an array of Fields which should be used if no fields are defined
58+
|
59+
*/
60+
61+
'autofields' => [
62+
'type' => [
63+
'tinyint(1)' => 'the42coders\TLAP\Fields\CheckboxField',
64+
'text' => 'the42coders\TLAP\Fields\TrixField',
65+
'timestamp' => 'the42coders\TLAP\Fields\TimeStampField',
66+
'datetime' => 'the42coders\TLAP\Fields\TimeStampField',
67+
'bigint' => 'the42coders\TLAP\Fields\NumberField',
68+
'bigint unsigned' => 'the42coders\TLAP\Fields\NumberField',
69+
],
70+
'name' => [
71+
'pw' => 'the42coders\TLAP\Fields\PasswordField',
72+
'password' => 'the42coders\TLAP\Fields\PasswordField',
73+
],
74+
],
75+
76+
'datatableFilter' => [
77+
'type' => [
78+
'text' => 'the42coders\TLAP\Filters\ShortenTextFilter',
79+
'timestamp' => 'the42coders\TLAP\Filters\FormatTimestamps',
80+
'datetime' => 'the42coders\TLAP\Filters\FormatTimestamps',
81+
],
82+
],
83+
3384
];

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"datatables.net-responsive-bs5": "^2.2.9",
3636
"jquery": "^3.5.1",
3737
"jquery-datatables-checkboxes": "^1.2.12",
38-
"sweetalert2": "^11.0.11"
38+
"sweetalert2": "^11.0.11",
39+
"trix": "^1.3.1"
3940
}
4041
}

public/css/tlap.css

Lines changed: 8562 additions & 3 deletions
Large diffs are not rendered by default.

public/js/tlap.js

Lines changed: 37355 additions & 2 deletions
Large diffs are not rendered by default.

resources/js/tlap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ try {
55

66
import 'bootstrap';
77
import 'datatables.net-bs5';
8+
import 'trix';
89
//import 'datatables.net-responsive-bs';
910
//import 'datatables.net-responsive-bs5';
1011
//import 'jquery-datatables-checkboxes';

resources/sass/tlap.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import "~datatables.net-bs5/css/dataTables.bootstrap5.css";
55
@import "~datatables.net-responsive-bs";
66
@import "~datatables.net-responsive-bs5";
7+
@import "~trix/dist/trix.css";
78

89
body{
910
background-color: #edf2f9;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script>
2+
$( document ).ready(function() {
3+
$('#{{$tableName}}').DataTable({
4+
"scrollX": true,
5+
"processing": true,
6+
"serverSide": true,
7+
"ajax": {
8+
"url": "{{ route('tlap.datatable', ['models' => $TLAPModel::getModelPluralName()]) }}",
9+
@if(!empty($model))
10+
"data": {
11+
"ids": {{ $model->$relation()->pluck('id') }}
12+
}
13+
@endif
14+
},
15+
'columnDefs': [
16+
{
17+
"targets": -1,
18+
"data": null,
19+
"defaultContent": "<button>Click!</button>"
20+
}
21+
],
22+
"columns": [
23+
@foreach($TLAPModel::getDatatableFields() as $fieldName)
24+
{ "data": "{{ $fieldName }}", "title": "{{ $fieldName }}" },
25+
@endforeach
26+
{"data": "",
27+
render : function(data, type, row) {
28+
console.log(row);
29+
return '' +
30+
'<a href="/admin/{{ $TLAPModel::getModelPluralName() }}/'+row.id+'/show" class="show"><i class="bi bi-eye"></i></a> ' +
31+
'<a href="/admin/{{ $TLAPModel::getModelPluralName() }}/'+row.id+'/edit" class="show"><i class="bi bi-pencil-square"></i></a> ' +
32+
'<a href="/admin/{{ $TLAPModel::getModelPluralName() }}/'+row.id+'/delete" class="show"><i class="bi bi-trash"></i></a>' +
33+
''
34+
35+
} },
36+
],
37+
'order': [[1, 'asc']]
38+
});
39+
});
40+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="mb-3 col-md-{{ $field->col ?? '12' }}">
2+
<label for="{{ $field->name }}" class="form-label">{{ $field->label ?? $field->name }}</label>
3+
<textarea class="form-control @error($field->name) is-invalid @enderror" id="{{ $field->name }}" rows="10" name="{{ $field->name }}" placeholder="{{ $field->label ?? $field->name }}" aria-describedby="{{ $field->name }}-error">
4+
@if(old($field->name)) {{ old($field->name) }} @else {{ $value }} @endif
5+
</textarea>
6+
@if(isset($field->description))
7+
<p class="mt-2 text-sm text-gray-500">
8+
{{ $field->description }}
9+
</p>
10+
@endif
11+
@error($field->name)
12+
<p class="invalid-feedback" id="{{ $field->name }}-error">{{ $message }}</p>
13+
@enderror
14+
</div>

0 commit comments

Comments
 (0)