@@ -15,12 +15,109 @@ You can install the package via composer:
1515composer require max-hutschenreiter/the-laravel-admin-panel
1616```
1717
18+ 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.
19+
20+ ``` php
21+ Route::group(['middleware' => ['auth']], function () {
22+ \the42coders\Workflows\Workflows::routes();
23+ });
24+ ```
25+
26+ You need to publish the assets of the Package
27+
28+ ``` bash
29+ php artisan vendor:publish --provider=" the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=assets
30+ ```
31+
32+ Other publishable Contents are
33+
34+ config
35+
36+ ``` bash
37+ php artisan vendor:publish --provider=" the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=config
38+ ```
39+
40+ language
41+
42+ ``` bash
43+ php artisan vendor:publish --provider=" the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=lang
44+ ```
45+
46+ views
47+
48+ ``` bash
49+ php artisan vendor:publish --provider=" the42coders\the-laravel-admin-panel\TLAPServiceProvider" --tag=views
50+ ```
51+
52+
1853## Usage
1954
55+ To generate the CRUD for a Model just add the TLAPAdminTrait to your Model.
56+
57+ ``` php
58+ use the42coders\TLAP\Traits\TLAPAdminTrait;
59+
60+ class User extends Model
61+ {
62+ use TLAPAdminTrait;
63+ ```
64+
65+ and register it in the config tlap.php.
66+
67+ ``` php
68+ 'models' => [
69+ 'users' => 'App\Models\User',
70+ ]
71+ ```
72+
73+ Now you can just visit the url of https://your-website.de/admin .
74+ You can change the url under which the admin panel will be accessible
75+ in the tlap.php config file with the path variable.
76+
77+ This package autoloads your relations if you use return types on them.
78+
79+ ``` php
80+ public function posts(): HasMany
81+ {
82+ return $this->hasMany('App\Models\Post');
83+ }
84+ ```
85+
86+ The package is guessing your application by its Database structure.
87+ Including validation. But you can overwrite this guessing by your own wishes.
88+
89+ You only need to add the static function fields to your Model and set the
90+ $fields array with your Field definitions. This is the area which might change
91+ a little before the final release.
92+
2093``` php
21- // Usage description here
94+ public static function fields()
95+ {
96+ self::$fields = [
97+ new TextField('name', 'Name'),
98+ new TextField('slug', 'Slug'),
99+ new TextField('description', 'Description', false),
100+ new TextField('menu', 'Menu'),
101+ new TextField('image', 'Image'),
102+ new TextField('parent_id', 'Parent ID'),
103+ ];
104+
105+ return self::$fields;
106+ }
22107```
23108
109+ By now we have the following Fields out of the box.
110+
111+ Field | Description
112+ ---- | -----------
113+ Checkbox | Default bs5 Checkbox
114+ File | Default bs5 Filepicker
115+ Select | Default bs5 Select field
116+ Text | Default bs5 text input field
117+ TextField | Default bs5 Textarea.
118+
119+ In the future it will be possible to add your own Fields as well.
120+
24121### Testing
25122
26123``` bash
0 commit comments