├── .github └── workflows │ └── run_tests.yml ├── .styleci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── config └── config.php ├── mix-manifest.json ├── package-lock.json ├── package.json ├── public ├── css │ └── tlap.css ├── fonts │ └── vendor │ │ ├── @fortawesome │ │ └── fontawesome-free │ │ │ ├── webfa-brands-400.eot │ │ │ ├── webfa-brands-400.svg │ │ │ ├── webfa-brands-400.ttf │ │ │ ├── webfa-brands-400.woff │ │ │ ├── webfa-brands-400.woff2 │ │ │ ├── webfa-regular-400.eot │ │ │ ├── webfa-regular-400.svg │ │ │ ├── webfa-regular-400.ttf │ │ │ ├── webfa-regular-400.woff │ │ │ ├── webfa-regular-400.woff2 │ │ │ ├── webfa-solid-900.eot │ │ │ ├── webfa-solid-900.svg │ │ │ ├── webfa-solid-900.ttf │ │ │ ├── webfa-solid-900.woff │ │ │ └── webfa-solid-900.woff2 │ │ └── bootstrap-icons │ │ ├── bootstrap-icons.woff │ │ └── bootstrap-icons.woff2 └── js │ ├── tlap.js │ └── tlap.js.LICENSE.txt ├── resources ├── js │ └── tlap.js ├── sass │ └── tlap.scss └── views │ ├── datatable │ └── datatable.blade.php │ ├── forms │ ├── checkbox_field.blade.php │ ├── hasone_field.blade.php │ ├── image_upload.blade.php │ ├── media_field.blade.php │ ├── number_field.blade.php │ ├── password_field.blade.php │ ├── read_only.blade.php │ ├── select_field.blade.php │ ├── text_field.blade.php │ ├── textarea_field.blade.php │ ├── timestamp_field.blade.php │ └── trix_field.blade.php │ ├── layouts │ ├── admin.blade.php │ ├── navbar.blade.php │ └── sidebar.blade.php │ └── pages │ ├── create.blade.php │ ├── edit.blade.php │ ├── index.blade.php │ ├── medialibrary │ └── index.blade.php │ ├── show.blade.php │ └── start.blade.php ├── src ├── Contracts │ ├── Fields │ │ └── Field.php │ └── Filters │ │ └── Filter.php ├── Fields │ ├── CheckboxField.php │ ├── Field.php │ ├── HasOneField.php │ ├── ImageUploadField.php │ ├── MediaField.php │ ├── NumberField.php │ ├── PasswordField.php │ ├── ReadOnlyField.php │ ├── SelectField.php │ ├── TextAreaField.php │ ├── TextField.php │ ├── TimeStampField.php │ └── TrixField.php ├── Filters │ ├── Filter.php │ ├── FormatTimestamps.php │ └── ShortenTextFilter.php ├── Http │ └── Controllers │ │ ├── TLAPController.php │ │ └── TLAPMediaController.php ├── TLAP.php ├── TLAPDataTable.php ├── TLAPFacade.php ├── TLAPModel.php ├── TLAPServiceProvider.php └── Traits │ └── TLAPAdminTrait.php └── webpack.mix.js /.github/workflows/run_tests.yml: -------------------------------------------------------------------------------- 1 | name: Testing 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | laravel-tests: 7 | runs-on: ubuntu-latest 8 | services: 9 | mysql: 10 | image: mysql:8 11 | env: 12 | MYSQL_ROOT_PASSWORD: root 13 | MYSQL_DATABASE: tlap_test 14 | ports: 15 | - 3306:3306 16 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Setup PHP 20 | uses: shivammathur/setup-php@v2 21 | with: 22 | php-version: 8 23 | - name: Install Dependencies 24 | run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist 25 | - name: Execute tests (Unit and Feature tests) via PHPUnit 26 | run: vendor/bin/phpunit 27 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | disabled: 4 | - single_class_element_per_statement 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `the-laravel-admin-panel` will be documented in this file 4 | 5 | ## 1.0.0 - 201X-XX-XX 6 | 7 | - initial release 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Max Hutschenreiter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adds a zero configuration Admin Panel to your Laravel Application 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://packagist.org/packages/the42coders/the-laravel-admin-panel) 4 | [![Build Status](https://img.shields.io/travis/the42coders/the-laravel-admin-panel/master.svg?style=flat-square)](https://travis-ci.org/the42coders/the-laravel-admin-panel) 5 | [![Quality Score](https://img.shields.io/scrutinizer/g/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://scrutinizer-ci.com/g/the42coders/the-laravel-admin-panel) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://packagist.org/packages/the42coders/the-laravel-admin-panel) 7 | 8 | ## Installation 9 | 10 | You can install the package via composer: 11 | 12 | ```bash 13 | composer require the42coders/the-laravel-admin-panel 14 | ``` 15 | 16 | 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. 17 | 18 | ```php 19 | Route::group(['middleware' => ['auth']], function () { 20 | \the42coders\TLAP\TLAP::routes(); 21 | }); 22 | ``` 23 | 24 | You need to publish the assets of the Package 25 | 26 | ```bash 27 | php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=assets 28 | ``` 29 | 30 | Other publishable Contents are 31 | 32 | config 33 | 34 | ```bash 35 | php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=config 36 | ``` 37 | 38 | language 39 | 40 | ```bash 41 | php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=lang 42 | ``` 43 | 44 | views 45 | 46 | ```bash 47 | php artisan vendor:publish --provider="the42coders\TLAP\TLAPServiceProvider" --tag=views 48 | ``` 49 | 50 | 51 | ## Usage 52 | 53 | To generate the CRUD for a Model just add the TLAPAdminTrait to your Model. 54 | 55 | ``` php 56 | use the42coders\TLAP\Traits\TLAPAdminTrait; 57 | 58 | class User extends Model 59 | { 60 | use TLAPAdminTrait; 61 | ``` 62 | 63 | and register it in the config tlap.php. 64 | 65 | ``` php 66 | 'models' => [ 67 | 'users' => 'App\Models\User', 68 | ] 69 | ``` 70 | 71 | Now you can just visit the url of https://your-website.de/admin. 72 | You can change the url under which the admin panel will be accessible 73 | in the tlap.php config file with the path variable. 74 | 75 | This package autoload your relations if you use return types on them. 76 | 77 | ``` php 78 | public function posts(): HasMany 79 | { 80 | return $this->hasMany('App\Models\Post'); 81 | } 82 | ``` 83 | 84 | The package is guessing your application by its Database structure. 85 | Including validation. But you can overwrite this guessing by your own wishes. 86 | 87 | You only need to add the static function fields to your Model and set the 88 | $fields array with your Field definitions. This is the area which might change 89 | a little before the final release. 90 | 91 | ``` php 92 | public static function fields() 93 | { 94 | self::$fields = [ 95 | new TextField('name', 'Name'), 96 | new TextField('slug', 'Slug'), 97 | new TextField('description', 'Description', false), 98 | new TextField('menu', 'Menu'), 99 | new TextField('image', 'Image'), 100 | new TextField('parent_id', 'Parent ID'), 101 | ]; 102 | 103 | return self::$fields; 104 | } 105 | ``` 106 | 107 | By now we have the following Fields out of the box. 108 | 109 | Field | Description 110 | ---- | ----------- 111 | Checkbox | Default bs5 Checkbox 112 | File | Default bs5 Filepicker 113 | Select | Default bs5 Select field 114 | Text | Default bs5 text input field 115 | TextField | Default bs5 Textarea. 116 | 117 | In the future it will be possible to add your own Fields as well. 118 | 119 | ### Testing 120 | 121 | ``` bash 122 | composer test 123 | ``` 124 | 125 | ### Changelog 126 | 127 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 128 | 129 | ## Contributing 130 | 131 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 132 | 133 | ### Security 134 | 135 | If you discover any security related issues, please email max@42coders.com instead of using the issue tracker. 136 | 137 | ## Credits 138 | 139 | - [Max Hutschenreiter](https://github.com/max-hutschenreiter) 140 | - [All Contributors](../../contributors) 141 | 142 | ## License 143 | 144 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 145 | 146 | ## Laravel Package Boilerplate 147 | 148 | This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com). 149 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "the42coders/the-laravel-admin-panel", 3 | "description": "A package to create an Admin panel with basic crud.", 4 | "keywords": [ 5 | "42coders", 6 | "the-laravel-admin-panel" 7 | ], 8 | "homepage": "https://github.com/42coders/the-laravel-admin-panel", 9 | "license": "MIT", 10 | "type": "library", 11 | "authors": [ 12 | { 13 | "name": "Max Hutschenreiter", 14 | "email": "max@42coders.com", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": ">7.1", 20 | "illuminate/support": "^9.18", 21 | "spatie/laravel-medialibrary": "^10.5", 22 | "yajra/laravel-datatables": "^9.0" 23 | }, 24 | "require-dev": { 25 | "orchestra/testbench": "7.*", 26 | "phpstan/phpstan": "^1.2", 27 | "phpunit/phpunit": "^9.0" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "the42coders\\TLAP\\": "src" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "the42coders\\TLAP\\Tests\\": "tests" 37 | } 38 | }, 39 | "scripts": { 40 | "test": "vendor/bin/phpunit", 41 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 42 | 43 | }, 44 | "config": { 45 | "sort-packages": true 46 | }, 47 | "extra": { 48 | "laravel": { 49 | "providers": [ 50 | "the42coders\\TLAP\\TLAPServiceProvider" 51 | ], 52 | "aliases": { 53 | "TLAP": "the42coders\\TLAP\\TLAPFacade" 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /config/config.php: -------------------------------------------------------------------------------- 1 | 'admin', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Models 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Define an array of Models you want to use in the-laravel-admin-panel 26 | | 27 | */ 28 | 29 | 'models' => [ 30 | //'users' => 'App\Models\User', 31 | ], 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Relations 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Define an array of Relation return types which will be automatically resolved in the show and edit view. 39 | | 40 | */ 41 | 42 | 'relations' => [ 43 | 'HasOne', 44 | 'HasMany', 45 | 'BelongsTo', 46 | 'BelongsToMany', 47 | 'MorphToMany', 48 | 'MorphTo' 49 | ], 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Auto Field discovery 54 | |-------------------------------------------------------------------------- 55 | | 56 | | Define an array of Fields which should be used if no fields are defined 57 | | 58 | */ 59 | 60 | 'autofields' => [ 61 | 'type' => [ 62 | 'tinyint(1)' => \the42coders\TLAP\Fields\CheckboxField::class, 63 | 'text' => \the42coders\TLAP\Fields\TrixField::class, 64 | 'timestamp' => \the42coders\TLAP\Fields\TimeStampField::class, 65 | 'datetime' => \the42coders\TLAP\Fields\TimeStampField::class, 66 | 'bigint' => \the42coders\TLAP\Fields\NumberField::class, 67 | 'bigint unsigned' => \the42coders\TLAP\Fields\NumberField::class, 68 | ], 69 | 'name' => [ 70 | 'id' => \the42coders\TLAP\Fields\ReadOnlyField::class, 71 | 'created_at' => \the42coders\TLAP\Fields\ReadOnlyField::class, 72 | 'updated_at' => \the42coders\TLAP\Fields\ReadOnlyField::class, 73 | 'deleted_at' => \the42coders\TLAP\Fields\ReadOnlyField::class, 74 | 'pw' => \the42coders\TLAP\Fields\PasswordField::class, 75 | 'password' => \the42coders\TLAP\Fields\PasswordField::class, 76 | ], 77 | ], 78 | 79 | 'datatableFilter' => [ 80 | 'type' => [ 81 | 'text' => \the42coders\TLAP\Filters\ShortenTextFilter::class, 82 | 'timestamp' => \the42coders\TLAP\Filters\FormatTimestamps::class, 83 | 'datetime' => \the42coders\TLAP\Filters\FormatTimestamps::class, 84 | ], 85 | ], 86 | 87 | 'datatableDontDisplay' => [ 88 | 'type' => ['text'], 89 | 'name' => ['deleted_at'], 90 | ], 91 | 92 | 'medialibrary' => [ 93 | 94 | ], 95 | ]; 96 | -------------------------------------------------------------------------------- /mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/public/js/tlap.js": "/public/js/tlap.js", 3 | "/public/css/tlap.css": "/public/css/tlap.css" 4 | } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "the-laravel-admin-panel", 3 | "version": "1.0.0", 4 | "description": "[![Latest Version on Packagist](https://img.shields.io/packagist/v/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://packagist.org/packages/the42coders/the-laravel-admin-panel) [![Build Status](https://img.shields.io/travis/the42coders/the-laravel-admin-panel/master.svg?style=flat-square)](https://travis-ci.org/42coders/the-laravel-admin-panel) [![Quality Score](https://img.shields.io/scrutinizer/g/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://scrutinizer-ci.com/g/the42coders/the-laravel-admin-panel) [![Total Downloads](https://img.shields.io/packagist/dt/the42coders/the-laravel-admin-panel.svg?style=flat-square)](https://packagist.org/packages/the42coders/the-laravel-admin-panel)", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "dev": "NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 11 | "watch": "NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 12 | "hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 13 | "production": "NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+ssh://git@bitbucket.org/maxhutschenreiter/workflow_package.git" 18 | }, 19 | "author": "", 20 | "license": "ISC", 21 | "homepage": "https://bitbucket.org/maxhutschenreiter/workflow_package#readme", 22 | "devDependencies": { 23 | "laravel-datatables-vite": "^0.4.0", 24 | "laravel-mix": "^5.0.5", 25 | "resolve-url-loader": "^3.1.0", 26 | "sass": "^1.26.10", 27 | "sass-loader": "^8.0.2", 28 | "vue-template-compiler": "^2.6.12" 29 | }, 30 | "dependencies": { 31 | "@fortawesome/fontawesome-free": "^5.14.0", 32 | "@uppy/core": "^3.0.2", 33 | "@uppy/dashboard": "^3.1.0", 34 | "@uppy/image-editor": "^2.0.1", 35 | "@uppy/tus": "^3.0.2", 36 | "bootstrap": "^5.0.0-beta2", 37 | "bootstrap-icons": "^1.4.0", 38 | "cropperjs": "^1.5.12", 39 | "datatables.net-bs5": "^1.10.25", 40 | "datatables.net-responsive-bs": "^2.2.9", 41 | "datatables.net-responsive-bs5": "^2.2.9", 42 | "dropzone": "^6.0.0-beta.2", 43 | "jquery": "^3.5.1", 44 | "jquery-datatables-checkboxes": "^1.2.12", 45 | "sortablejs": "^1.15.0", 46 | "sweetalert2": "^11.0.11", 47 | "trix": "^1.3.1" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/bootstrap-icons/bootstrap-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/bootstrap-icons/bootstrap-icons.woff -------------------------------------------------------------------------------- /public/fonts/vendor/bootstrap-icons/bootstrap-icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42coders/the-laravel-admin-panel/8316e0fd2e2ddcfbfb1b218b1118051046198abe/public/fonts/vendor/bootstrap-icons/bootstrap-icons.woff2 -------------------------------------------------------------------------------- /public/js/tlap.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v5.0.2 (https://getbootstrap.com/) 3 | * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 5 | */ 6 | 7 | /*! 8 | * Sizzle CSS Selector Engine v2.3.6 9 | * https://sizzlejs.com/ 10 | * 11 | * Copyright JS Foundation and other contributors 12 | * Released under the MIT license 13 | * https://js.foundation/ 14 | * 15 | * Date: 2021-02-16 16 | */ 17 | 18 | /*! DataTables 1.10.25 19 | * ©2008-2021 SpryMedia Ltd - datatables.net/license 20 | */ 21 | 22 | /*! DataTables Bootstrap 5 integration 23 | * 2020 SpryMedia Ltd - datatables.net/license 24 | */ 25 | -------------------------------------------------------------------------------- /resources/js/tlap.js: -------------------------------------------------------------------------------- 1 | try { 2 | //window.$ = window.jQuery = require('jquery'); 3 | } catch (e) {} 4 | 5 | 6 | import 'bootstrap'; 7 | import 'trix'; 8 | import 'laravel-datatables-vite'; 9 | import Uppy from "@uppy/core"; 10 | import Dashboard from "@uppy/dashboard"; 11 | import Tus from "@uppy/tus"; 12 | import ImageEditor from '@uppy/image-editor' 13 | //import Sortable from 'sortablejs'; 14 | //import Dropzone from "dropzone"; 15 | //import Cropper from "cropperjs"; 16 | //require('../../node_modules/cropperjs/dist/cropper'); 17 | //import Sortable from 'sortablejs'; 18 | //import 'datatables.net-responsive-bs'; 19 | //import 'datatables.net-responsive-bs5'; 20 | //import 'jquery-datatables-checkboxes'; 21 | 22 | window.Uppy = Uppy; 23 | window.Dashboard = Dashboard; 24 | window.Tus = Tus; 25 | window.ImageEditor = ImageEditor; 26 | 27 | 28 | //window.Cropper = Cropper; 29 | //window.Dropzone = Dropzone; 30 | 31 | $.ajaxSetup({ 32 | headers: { 33 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 34 | } 35 | }); 36 | 37 | addEventListener("trix-attachment-add", function(event) { 38 | if (event.attachment.file) { 39 | uploadFileAttachment(event.attachment) 40 | } 41 | }) 42 | 43 | function uploadFileAttachment(attachment) { 44 | uploadFile(attachment.file, setProgress, setAttributes) 45 | 46 | function setProgress(progress) { 47 | attachment.setUploadProgress(progress) 48 | } 49 | 50 | function setAttributes(attributes) { 51 | attachment.setAttributes(attributes) 52 | } 53 | } 54 | 55 | function uploadFile(file, progressCallback, successCallback) { 56 | var formData = createFormData(file); 57 | var xhr = new XMLHttpRequest(); 58 | 59 | xhr.open("POST", base_url + 'trix-upload', true); 60 | xhr.setRequestHeader( 'X-CSRF-TOKEN', getMeta( 'csrf-token') ); 61 | 62 | xhr.upload.addEventListener("progress", function(event) { 63 | var progress = event.loaded / event.total * 100 64 | progressCallback(progress) 65 | }) 66 | 67 | xhr.addEventListener("load", function(event) { 68 | var attributes = { 69 | url: xhr.responseText, 70 | href: xhr.responseText + "?content-disposition=attachment" 71 | } 72 | successCallback(attributes) 73 | }) 74 | 75 | xhr.send(formData) 76 | } 77 | 78 | function createFormData(file) { 79 | var data = new FormData() 80 | data.append("Content-Type", file.type) 81 | data.append("file", file) 82 | return data 83 | } 84 | 85 | function getMeta(metaName) { 86 | const metas = document.getElementsByTagName('meta'); 87 | 88 | for (let i = 0; i < metas.length; i++) { 89 | if (metas[i].getAttribute('name') === metaName) { 90 | return metas[i].getAttribute('content'); 91 | } 92 | } 93 | 94 | return ''; 95 | } 96 | -------------------------------------------------------------------------------- /resources/sass/tlap.scss: -------------------------------------------------------------------------------- 1 | @import "~bootstrap/dist/css/bootstrap.min.css"; 2 | @import "~bootstrap-icons/font/bootstrap-icons.css"; 3 | @import '~@fortawesome/fontawesome-free/css/all'; 4 | @import "~datatables.net-bs5/css/dataTables.bootstrap5.css"; 5 | @import "~datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css"; 6 | @import '~datatables.net-select-bs5/css/select.bootstrap5.css'; 7 | @import "~trix/dist/trix.css"; 8 | @import "~@uppy/core/dist/style.css"; 9 | @import "~@uppy/dashboard/dist/style.css"; 10 | @import "~@uppy/image-editor/dist/style.css"; 11 | 12 | body{ 13 | background-color: #edf2f9; 14 | } 15 | 16 | .nav{ 17 | padding-top: 2rem; 18 | a{ 19 | color: #212529; 20 | } 21 | .nav-item{ 22 | padding-left: 1rem; 23 | } 24 | } 25 | 26 | .nav-pills .nav-link.active, .nav-pills .show>.nav-link{ 27 | background-color: white; 28 | color: #fa5661; 29 | } 30 | 31 | .card{ 32 | border-radius: calc(.375rem - 0px) calc(.375rem - 0px) 0 0; 33 | box-shadow: 0 7px 14px 0 rgb(65 69 88 / 10%), 0 3px 6px 0 rgb(0 0 0 / 7%); 34 | border-radius: .375rem; 35 | border: 0 solid #edf2f9; 36 | background-color: #fff; 37 | background-clip: border-box; 38 | .card-header{ 39 | border-radius: calc(.375rem - 0px) calc(.375rem - 0px) 0 0; 40 | padding: 1rem 1.25rem; 41 | margin-bottom: 0; 42 | background-color: #fff; 43 | border-bottom: 0 solid #edf2f9; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /resources/views/datatable/datatable.blade.php: -------------------------------------------------------------------------------- 1 | 39 | -------------------------------------------------------------------------------- /resources/views/forms/checkbox_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | name)) checked="checked" @else @if($value) checked="checked" @endif @endif value="1"> 4 | 7 | @if(isset($field->description)) 8 |

9 | {{ $field->description }} 10 |

11 | @endif 12 | @error($field->name) 13 |

{{ $message }}

14 | @enderror 15 |
16 | -------------------------------------------------------------------------------- /resources/views/forms/hasone_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 9 | @if(isset($field->description)) 10 |

11 | {{ $field->description }} 12 |

13 | @endif 14 | @error($field->name) 15 |

{{ $message }}

16 | @enderror 17 |
18 | -------------------------------------------------------------------------------- /resources/views/forms/image_upload.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ $value }}" @endif> 4 | @if(isset($field->description)) 5 |

6 | {{ $field->description }} 7 |

8 | @endif 9 | @error($field->name) 10 |

{{ $message }}

11 | @enderror 12 | 13 |
14 | 19 | -------------------------------------------------------------------------------- /resources/views/forms/media_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 9 |
10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | 30 | -------------------------------------------------------------------------------- /resources/views/forms/number_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ $value }}" @endif> 5 | @if(isset($field->description)) 6 |

7 | {{ $field->description }} 8 |

9 | @endif 10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | -------------------------------------------------------------------------------- /resources/views/forms/password_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ $value }}" @endif> 5 | @if(isset($field->description)) 6 |

7 | {{ $field->description }} 8 |

9 | @endif 10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | -------------------------------------------------------------------------------- /resources/views/forms/read_only.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ $value }}" @endif readonly> 5 | @if(isset($field->description)) 6 |

7 | {{ $field->description }} 8 |

9 | @endif 10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | -------------------------------------------------------------------------------- /resources/views/forms/select_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 9 | @if(isset($field->description)) 10 |

11 | {{ $field->description }} 12 |

13 | @endif 14 | @error($field->name) 15 |

{{ $message }}

16 | @enderror 17 |
18 | -------------------------------------------------------------------------------- /resources/views/forms/text_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ $value }}" @endif> 5 | @if(isset($field->description)) 6 |

7 | {{ $field->description }} 8 |

9 | @endif 10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | -------------------------------------------------------------------------------- /resources/views/forms/textarea_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 | @if(isset($field->description)) 7 |

8 | {{ $field->description }} 9 |

10 | @endif 11 | @error($field->name) 12 |

{{ $message }}

13 | @enderror 14 |
15 | -------------------------------------------------------------------------------- /resources/views/forms/timestamp_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | name)) value="{{ old($field->name) }}" @else value="{{ isset($value) ? $value->format('Y-m-d\TH:i:s') : '' }}" @endif> 5 | @if(isset($field->description)) 6 |

7 | {{ $field->description }} 8 |

9 | @endif 10 | @error($field->name) 11 |

{{ $message }}

12 | @enderror 13 |
14 | -------------------------------------------------------------------------------- /resources/views/forms/trix_field.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | @if(old($field->name)) {!! old($field->name) !!} @else {!! $value !!} @endif 6 | 7 | @if(isset($field->description)) 8 |

9 | {{ $field->description }} 10 |

11 | @endif 12 | @error($field->name) 13 |

{{ $message }}

14 | @enderror 15 |
16 | -------------------------------------------------------------------------------- /resources/views/layouts/admin.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ env('APP_NAME') }} - Admin 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | @include('tlap::layouts.navbar') 24 |
25 | @include('tlap::layouts.sidebar') 26 |
27 |
28 |

@yield('content-header')

29 |
@yield('content')
30 |
31 |
32 |
33 |
34 | 37 | @yield('scripts') 38 | 39 | 40 | -------------------------------------------------------------------------------- /resources/views/layouts/navbar.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 10 |
11 | -------------------------------------------------------------------------------- /resources/views/layouts/sidebar.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 30 |
31 | {{-- --}} 47 |
48 |
49 | {{-- 50 | 61 | --}} 62 | -------------------------------------------------------------------------------- /resources/views/pages/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content-header') 4 |

{{ $TLAPModel::getModelName() }}

5 | @endsection 6 | 7 | @section('content') 8 |
9 | @csrf 10 | {!! $TLAPModel->getForm() !!} 11 |
 
12 | Zurück 13 | 14 |
15 | @endsection 16 | -------------------------------------------------------------------------------- /resources/views/pages/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content-header') 4 |

{{ $model::getModelName() }}

5 | @endsection 6 | 7 | @section('content') 8 |
9 | @csrf 10 | {!! $model->getForm($model) !!} 11 |
 
12 | Zurück 13 | 14 |
15 |
16 | @foreach($model->withRelations() as $relation) 17 |

{{ $relation }}

18 | @if(empty($model->$relation) || $model->$relation->count() <= 0) 19 |

No relatated Models found

20 | @else 21 | 22 |
23 | @include('tlap::datatable.datatable', ['tableName' => 'datatable-'.$relation, 'TLAPModel' => $model->$relation()->first(), 'relation'=> $relation]) 24 | @endif 25 | @endforeach 26 |
27 | @endsection 28 | -------------------------------------------------------------------------------- /resources/views/pages/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content-header') 4 |
5 |
6 |

{{ $TLAPModel::getModelName() }}

7 |
8 |
9 | 10 |
11 |
12 | @endsection 13 | 14 | @section('content') 15 | {{ $dataTable->table() }} 16 | @endsection 17 | 18 | @section('scripts') 19 | {{ $dataTable->scripts(attributes: ['type' => 'module']) }} 20 | 21 | @endsection 22 | -------------------------------------------------------------------------------- /resources/views/pages/medialibrary/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content-header') 4 |
5 |
6 |

Media Library

7 |
8 |
9 | 10 |
11 |
12 | @endsection 13 | 14 | @section('content') 15 |
16 |
17 | @foreach(config('tlap.medialibrary') as $name => $model) 18 | {{ $name }} 19 | @endforeach 20 |
21 |
22 | @foreach($images as $image) 23 |
24 | 25 | {{ $image->file_name }} {{ $image->human_readable_size }} {{ $image->mime_type }} 26 |
27 | @endforeach 28 |
29 |
30 | @endsection 31 | 32 | @section('scripts') 33 | 34 | @endsection 35 | -------------------------------------------------------------------------------- /resources/views/pages/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content-header') 4 |
5 |
6 |

{{ $TLAPModel::getModelName() }}

7 |
8 |
9 | 10 | {!! $model->getActions() !!} 11 |
12 |
13 | @endsection 14 | 15 | @section('content') 16 | 17 | @foreach($model->getTLAPTableStructure() as $fieldName => $fieldValue) 18 | 19 | 20 | 21 | 22 | @endforeach 23 |
{{ $fieldName }}{{ $model->$fieldName }}
24 |
25 | @foreach($model->withRelations() as $relation) 26 |

{{ $relation }}

27 | @if(empty($model->$relation) || $model->$relation->count() <= 0) 28 |

No relatated Models found

29 | @else 30 | 31 |
32 | @include('tlap::datatable.datatable', ['tableName' => 'datatable-'.$relation, 'TLAPModel' => $model->$relation()->first(), 'relation'=> $relation]) 33 | @endif 34 | @endforeach 35 |
36 | 37 | Zurück 38 | @endsection 39 | -------------------------------------------------------------------------------- /resources/views/pages/start.blade.php: -------------------------------------------------------------------------------- 1 | @extends('tlap::layouts.admin') 2 | 3 | @section('content') 4 | Admin 5 | @endsection 6 | -------------------------------------------------------------------------------- /src/Contracts/Fields/Field.php: -------------------------------------------------------------------------------- 1 | name = $name; 39 | $this->template = $template ?? $this->defaultTemplate; 40 | $this->label = $label; 41 | $this->description = $description; 42 | $this->validation = $validation; 43 | $this->col = $col ?? $this->defaultCol; 44 | $this->defaultValue = $defaultValue; 45 | $this->dataTable = $dataTable; 46 | $this->editable = $editable; 47 | } 48 | 49 | public function __toString(){ 50 | return $this->name; 51 | } 52 | 53 | public function getValue(Model $model = null) 54 | { 55 | if($model === null){ 56 | return $this->defaultValue; 57 | } 58 | 59 | $fieldName = $this->name; 60 | 61 | return $model->$fieldName ?? $this->defaultValue; 62 | } 63 | 64 | public function getInput($value) 65 | { 66 | return $value; 67 | } 68 | 69 | public function render($model = null) 70 | { 71 | return view( $this->template, ['field' => $this, 'value' => $this->getValue($model)]); 72 | } 73 | 74 | public function preProcessInput($value, Request $request, $model = null) 75 | { 76 | return $value; 77 | } 78 | 79 | public function postProcessInput($value, Request $request, $model) 80 | { 81 | return $value; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Fields/HasOneField.php: -------------------------------------------------------------------------------- 1 | relations = $model::select('id', $relationDisplayName)->get(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Fields/ImageUploadField.php: -------------------------------------------------------------------------------- 1 | hasFile($this->name) && $request->file($this->name)->isValid()){ 34 | $model->addMediaFromRequest($this->name)->toMediaCollection($this->name); 35 | } 36 | 37 | return $value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Fields/MediaField.php: -------------------------------------------------------------------------------- 1 | options = $options; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Fields/TextAreaField.php: -------------------------------------------------------------------------------- 1 | format('d.m.Y H:i'); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Filters/ShortenTextFilter.php: -------------------------------------------------------------------------------- 1 | render('tlap::pages.index', [ 26 | // 'models' => $models, 27 | 'TLAPModel' => $TLAPModel, 28 | ]); 29 | 30 | return view('tlap::pages.index', [ 31 | 'models' => $models, 32 | 'TLAPModel' => $TLAPModel, 33 | ]); 34 | } 35 | 36 | public function show($models, $id) 37 | { 38 | $TLAPModel = TLAPModel::getModel($models); 39 | 40 | $model = $TLAPModel::where('id', $id)->with($TLAPModel->withRelations())->first(); 41 | 42 | return view('tlap::pages.show', [ 43 | 'model' => $model, 44 | 'TLAPModel' => $TLAPModel, 45 | ]); 46 | } 47 | 48 | public function edit($models, $id) 49 | { 50 | $TLAPModel = TLAPModel::getModel($models); 51 | 52 | $model = $TLAPModel::find($id); 53 | 54 | return view('tlap::pages.edit', [ 55 | 'model' => $model, 56 | 'TLAPModel' => $TLAPModel, 57 | ]); 58 | } 59 | 60 | public function update($models, $id, Request $request) 61 | { 62 | $TLAPModel = TLAPModel::getModel($models); 63 | 64 | $model = $TLAPModel::find($id); 65 | $validated = $request->validate($TLAPModel->validation()); 66 | 67 | $input = $request->all(); 68 | 69 | if($model::fields()) { 70 | foreach ($model::fields() as $field) { 71 | if (array_key_exists($field->name, $input)) { 72 | $input[$field->name] = $field->preProcessInput($input[$field->name], $request, $model); 73 | } 74 | } 75 | } 76 | 77 | if (empty($input['pw'])){ 78 | unset($input['pw']); 79 | } else { 80 | $input['pw'] = Hash::make($input['pw']); 81 | } 82 | 83 | if (empty($input['password'])){ 84 | unset($input['password']); 85 | } else { 86 | $input['password'] = Hash::make($input['password']); 87 | } 88 | 89 | if(isset($input['_token'])){ 90 | unset($input['_token']); 91 | } 92 | 93 | $model->update($input); 94 | 95 | if($model::fields()) { 96 | foreach ($model::fields() as $field) { 97 | if (array_key_exists($field->name, $input)) { 98 | $input[$field->name] = $field->postProcessInput($input[$field->name], $request, $model); 99 | } 100 | } 101 | } 102 | 103 | return redirect()->route('tlap.show', ['models' => $model->getModelPluralName(), 'id' => $model->id]); 104 | } 105 | 106 | public function create($models) 107 | { 108 | $TLAPModel = TLAPModel::getModel($models); 109 | 110 | return view('tlap::pages.create', [ 111 | 'TLAPModel' => $TLAPModel, 112 | ]); 113 | } 114 | 115 | public function store($models, Request $request) 116 | { 117 | $TLAPModel = TLAPModel::getModel($models); 118 | 119 | $validated = $request->validate($TLAPModel->validation()); 120 | 121 | $input = $request->all(); 122 | 123 | if($TLAPModel::fields()) { 124 | foreach ($TLAPModel::fields() as $field) { 125 | if (array_key_exists($field->name, $input)) { 126 | $input[$field->name] = $field->preProcessInput($input[$field->name], $request); 127 | } 128 | } 129 | } 130 | 131 | if(isset($input['pw'])){ 132 | $input['pw'] = Hash::make($input['pw']); 133 | } 134 | 135 | if(isset($input['_token'])){ 136 | unset($input['_token']); 137 | } 138 | 139 | if(isset($input['password'])){ 140 | $input['password'] = Hash::make($input['password']); 141 | } 142 | 143 | $createdModel = $TLAPModel::create($input); 144 | 145 | if($createdModel::fields()) { 146 | foreach ($createdModel::fields() as $field) { 147 | if (array_key_exists($field->name, $input)) { 148 | $input[$field->name] = $field->postProcessInput($input[$field->name], $request, $createdModel); 149 | } 150 | } 151 | } 152 | 153 | return redirect()->route('tlap.show', ['models' => $createdModel->getModelPluralName(), 'id' => $createdModel->id]); 154 | } 155 | 156 | public function datatable($models, Request $request) 157 | { 158 | $TLAPModel = TLAPModel::getModel($models); 159 | 160 | if(empty($request->ids)){ 161 | return $TLAPModel->getDataTable($request); 162 | } 163 | 164 | return $TLAPModel->getDatatableIdFiltered($request, $request->ids); 165 | } 166 | 167 | public function delete($models, $id) 168 | { 169 | $TLAPModel = TLAPModel::getModel($models); 170 | 171 | $model = $TLAPModel::find($id); 172 | 173 | if(empty($model)){ 174 | return redirect()->route('tlap.index', ['models' => $TLAPModel->getModelPluralName()]); 175 | } 176 | 177 | $model->delete(); 178 | 179 | return redirect()->route('tlap.index', ['models' => $model->getModelPluralName()]); 180 | } 181 | 182 | public function trixUpload(Request $request) 183 | { 184 | if($request->hasFile('file')) { 185 | $filenameWithExtension = $request->file('file')->getClientOriginalName(); 186 | $filename = pathinfo($filenameWithExtension, PATHINFO_FILENAME); 187 | $extension = $request->file('file')->getClientOriginalExtension(); 188 | $filenameToStore = $filename.'_'.time().'.'.$extension; 189 | $request->file('file')->storeAs('public/uploads', $filenameToStore); 190 | $path = asset('storage/uploads/'.$filenameToStore); 191 | 192 | echo $path; 193 | exit; 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /src/Http/Controllers/TLAPMediaController.php: -------------------------------------------------------------------------------- 1 | limit(20)->get(); 14 | 15 | return view('tlap::pages.medialibrary.index', [ 16 | 'images' => $images, 17 | ]); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/TLAP.php: -------------------------------------------------------------------------------- 1 | config('tlap.path'), 'namespace' => __NAMESPACE__.'\Http\Controllers'], function () { 25 | 26 | Route::get('/medialibrary', [TLAPMediaController::class, 'index'])->name('tlap.medialibrary.index'); 27 | 28 | Route::get('/', 'TLAPController@start')->name('tlap.start'); 29 | Route::post('/trix-upload', [TLAPController::class, 'trixUpload'])->name('tlap.trix-upload'); 30 | Route::get('/{models}/', [TLAPController::class, 'index'])->name('tlap.index'); 31 | Route::post('/{models}/', [TLAPController::class, 'store'])->name('tlap.store'); 32 | Route::get('/{models}/create', [TLAPController::class, 'create'])->name('tlap.create'); 33 | Route::get('/{models}/{id}/show', [TLAPController::class, 'show'])->name('tlap.show'); 34 | Route::get('/{models}/{id}/edit', [TLAPController::class, 'edit'])->name('tlap.edit'); 35 | Route::post('/{models}/{id}/', [TLAPController::class, 'update'])->name('tlap.update'); 36 | Route::get('/{models}/{id}/delete', [TLAPController::class, 'delete'])->name('tlap.delete'); 37 | Route::get('/{models}/datatable', [TLAPController::class, 'datatable'])->name('tlap.datatable'); 38 | }); 39 | } 40 | 41 | public static function getForm($columnName, $columnInfo, $model = null) 42 | { 43 | $autoFieldName = config('tlap.autofields.name.' . $columnName); 44 | $autoFieldType = config('tlap.autofields.type.' . $columnInfo['type']); 45 | 46 | if (class_exists($autoFieldName)){ 47 | $field = new $autoFieldName($columnName); 48 | return $field->render($model); 49 | } 50 | 51 | if (class_exists($autoFieldType)){ 52 | $field = new $autoFieldType($columnName); 53 | return $field->render($model); 54 | } 55 | 56 | $field = new TextField($columnName); 57 | 58 | return $field->render($model); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/TLAPDataTable.php: -------------------------------------------------------------------------------- 1 | DtModel = $model; 21 | } 22 | 23 | public function dataTable(QueryBuilder $query): EloquentDataTable 24 | { 25 | 26 | $dataTable = (new EloquentDataTable($query))->setRowId('id') 27 | ->addColumn('action', function($data){ 28 | return ' 29 | 30 | '; 31 | }); 32 | 33 | $columnStructure = $this->DtModel->getTLAPTableStructure(); 34 | 35 | foreach($columnStructure as $columnKey => $columnValue){ 36 | $filterName = config('tlap.datatableFilter.type.' . $columnValue['type']); 37 | if (class_exists($filterName)) { 38 | $dataTable->editColumn($columnKey, function ($value) use ($filterName, $columnKey){ 39 | $filter = app($filterName); 40 | return $filter->filter($value->{$columnKey}); 41 | }); 42 | } 43 | } 44 | 45 | return $dataTable; 46 | } 47 | 48 | public function query(): QueryBuilder 49 | { 50 | return $this->DtModel->newQuery(); 51 | } 52 | 53 | public function html(): HtmlBuilder 54 | { 55 | return $this->builder() 56 | ->setTableId('users-table') 57 | ->columns($this->getColumns()) 58 | ->minifiedAjax() 59 | ->orderBy(1) 60 | ->selectStyleMultiShift() 61 | ->buttons([ 62 | Button::make('add'), 63 | Button::make('excel'), 64 | Button::make('csv'), 65 | Button::make('pdf'), 66 | Button::make('print'), 67 | Button::make('reset'), 68 | Button::make('reload'), 69 | ]); 70 | } 71 | 72 | public function getColumns(): array 73 | { 74 | $columns = $this->DtModel->getDatatableFields(); 75 | 76 | $DataTableColumns = []; 77 | 78 | $DataTableColumns[] = Column::checkbox(''); 79 | 80 | foreach($columns as $column){ 81 | $DataTableColumns[] = Column::make($column); 82 | } 83 | 84 | $DataTableColumns[] = Column::computed('action'); 85 | 86 | return $DataTableColumns; 87 | } 88 | 89 | protected function filename(): string 90 | { 91 | return $this->DtModel->getModelName() . '_' . date('YmdHis'); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/TLAPFacade.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom(__DIR__.'/../resources/lang', 'tlap'); 18 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'tlap'); 19 | // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); 20 | // $this->loadRoutesFrom(__DIR__.'/routes.php'); 21 | 22 | if ($this->app->runningInConsole()) { 23 | $this->publishes([ 24 | __DIR__.'/../config/config.php' => config_path('tlap.php'), 25 | ], 'config'); 26 | 27 | // Publishing the views. 28 | $this->publishes([ 29 | __DIR__.'/../resources/views' => resource_path('views/vendor/tlap'), 30 | ], 'views'); 31 | 32 | // Publishing assets. 33 | $this->publishes([ 34 | __DIR__.'/../public/css' => public_path('vendor/tlap/css'), 35 | __DIR__.'/../public/js' => public_path('vendor/tlap/js'), 36 | __DIR__.'/../public/fonts' => public_path('public/fonts'), 37 | ], 'assets'); 38 | 39 | // Publishing the translation files. 40 | /*$this->publishes([ 41 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/tlap'), 42 | ], 'lang');*/ 43 | 44 | // Registering package commands. 45 | // $this->commands([]); 46 | } 47 | } 48 | 49 | /** 50 | * Register the application services. 51 | */ 52 | public function register() 53 | { 54 | // Automatically apply the package configuration 55 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'tlap'); 56 | 57 | // Register the main class to use with the facade 58 | $this->app->singleton('tlap', function () { 59 | return new TLAP; 60 | }); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Traits/TLAPAdminTrait.php: -------------------------------------------------------------------------------- 1 | Field] = [ 31 | 'type' => $column->Type, 32 | 'nullable' => $column->Null, 33 | 'key' => $column->Key, 34 | 'default' => $column->Default, 35 | 'extra' => $column->Extra, 36 | ]; 37 | } 38 | 39 | return $structure; 40 | } 41 | 42 | public function withRelations(): array 43 | { 44 | return Arr::pluck($this->getEloquentRelations(), 'name'); 45 | } 46 | 47 | public function getEloquentRelations(): array 48 | { 49 | $reflector = new ReflectionClass(self::class); 50 | 51 | $relations = []; 52 | foreach ($reflector->getMethods() as $reflectionMethod) { 53 | $returnType = $reflectionMethod->getReturnType(); 54 | if ($returnType) { 55 | if (in_array(class_basename($returnType->getName()), config('tlap.relations'))) { 56 | $relations[] = $reflectionMethod; 57 | } 58 | } 59 | } 60 | 61 | return $relations; 62 | } 63 | 64 | public static function getModelName(): string 65 | { 66 | return class_basename(__CLASS__); 67 | } 68 | 69 | public function getModelPluralName(): string 70 | { 71 | return Str::lower(Str::plural(self::getModelName())); 72 | } 73 | 74 | public function getTLAPStaticTableName() 75 | { 76 | return (new static)->getTable(); 77 | } 78 | 79 | public function getTLAPTableStructure(): array 80 | { 81 | $tableName = $this->getTLAPStaticTableName(); 82 | 83 | return $this->getTLAPStaticColumnStructure($tableName); 84 | } 85 | 86 | public function getForm($model = null): string 87 | { 88 | if(empty(self::fields())) { 89 | 90 | $tableStructure = $this->getTLAPTableStructure(); 91 | $form = ''; 92 | foreach ($tableStructure as $columnName => $column) { 93 | $form .= TLAP::getForm($columnName, $column, $model); 94 | } 95 | return $form; 96 | } 97 | 98 | $form = ''; 99 | 100 | /** @var Field $field */ 101 | foreach(self::fields() as $field) { 102 | $form .= $field->render($model); 103 | } 104 | 105 | return $form; 106 | } 107 | 108 | public function getColumnNames(): array 109 | { 110 | return array_keys($this->getTLAPTableStructure()); 111 | } 112 | 113 | public function getDatatableFields(): array 114 | { 115 | if (empty(self::fields())){ 116 | return array_keys($this->cleanData($this->getTLAPTableStructure())); 117 | } 118 | 119 | $columns = []; 120 | 121 | foreach(self::fields() as $field){ 122 | if($field->dataTable){ 123 | $columns[] = $field; 124 | } 125 | } 126 | 127 | return $columns; 128 | } 129 | 130 | public function cleanData($array): array 131 | { 132 | unset($array['password'], $array['remember_token']); 133 | 134 | foreach($array as $dataKey => $dataValue){ 135 | if(in_array($dataValue['type'], config('tlap.datatableDontDisplay.type'))){ 136 | unset($array[$dataKey]); 137 | } 138 | if(in_array($dataKey, config('tlap.datatableDontDisplay.name'))){ 139 | unset($array[$dataKey]); 140 | } 141 | } 142 | 143 | return $array; 144 | } 145 | 146 | public function validation():array 147 | { 148 | $validation = []; 149 | 150 | 151 | $columns = $this->getTLAPTableStructure(); 152 | 153 | 154 | foreach($columns as $columnName => $column){ 155 | if($column['nullable'] === 'NO' && $column['key'] !== 'PRI'){ 156 | $validation[$columnName] = 'required'; 157 | } 158 | } 159 | 160 | 161 | if(!empty(self::fields())) { 162 | foreach (self::fields() as $field) { 163 | if (!empty($field->validation)) { 164 | $validation[$field->name] = $field->validation; 165 | } 166 | } 167 | } 168 | 169 | return $validation; 170 | } 171 | 172 | 173 | 174 | public function getDatatable(Request $request, $ids = null): \Illuminate\Http\JsonResponse 175 | { 176 | $totalData = self::count(); 177 | 178 | $totalFiltered = $totalData; 179 | 180 | $columns = $this->getColumnNames(); 181 | 182 | $limit = $request->input('length'); 183 | $start = $request->input('start'); 184 | $order = $columns[$request->input('order.0.column')]; 185 | $dir = $request->input('order.0.dir'); 186 | 187 | if ($columns[0] !== 'id'){ 188 | array_unshift($columns, 'id'); 189 | } 190 | 191 | if (empty($request->input('search.value'))) 192 | { 193 | $data = self::select($columns) 194 | ->offset($start) 195 | ->limit($limit) 196 | ->orderBy($order, $dir) 197 | ->get(); 198 | } else { 199 | $search = $request->input ('search.value'); 200 | 201 | $data = self::query()->select($columns); 202 | foreach($this->getColumnNames() as $column){ 203 | $data = $data->orWhere($column, 'LIKE', "%{$search}%"); 204 | } 205 | $data = $data 206 | ->offset($start) 207 | ->limit($limit) 208 | ->orderBy($order, $dir) 209 | ->get(); 210 | 211 | $totalFiltered = self::query(); 212 | foreach($this->getColumnNames() as $column){ 213 | $totalFiltered = $totalFiltered->orWhere($column, 'LIKE', "%{$search}%"); 214 | } 215 | $totalFiltered = $totalFiltered->count(); 216 | } 217 | 218 | $columnStructure = $this->getTLAPTableStructure(); 219 | $data = $this->applyDataFilter($data->toArray(), $columnStructure); 220 | 221 | return response()->json([ 222 | 'draw' => intval($request->input('draw')), 223 | "recordsTotal"=> intval($totalData), 224 | "recordsFiltered"=> intval($totalFiltered), 225 | 'data' => $data 226 | ]); 227 | } 228 | 229 | public function applyDataFilter(array $data, array $columnsStructure): array 230 | { 231 | $columnStructure = $this->getTLAPTableStructure(); 232 | 233 | foreach($data as $dataKey => $dataValue){ 234 | foreach($columnStructure as $columnKey => $columnValue){ 235 | if(!isset($data[$dataKey][$columnKey])){ 236 | continue; 237 | } 238 | $filterName = config('tlap.datatableFilter.type.' . $columnValue['type']); 239 | if (class_exists($filterName)) { 240 | $filter = app($filterName); 241 | $data[$dataKey][$columnKey] = $filter->filter($dataValue[$columnKey]); 242 | } 243 | } 244 | } 245 | 246 | return $data; 247 | } 248 | 249 | public function getDatatableIdFiltered(Request $request, $ids = null): \Illuminate\Http\JsonResponse 250 | { 251 | $totalData = self::whereIn('id', $ids)->count(); 252 | 253 | $totalFiltered = $totalData; 254 | 255 | $columns = self::getColumnNames(); 256 | 257 | $limit = $request->input('length'); 258 | $start = $request->input('start'); 259 | $order = $columns[$request->input('order.0.column')]; 260 | $dir = $request->input('order.0.dir'); 261 | 262 | if($columns[0] !== 'id'){ 263 | array_unshift($columns, 'id'); 264 | } 265 | 266 | if(empty($request->input('search.value'))) 267 | { 268 | $data = self::select($columns) 269 | ->whereIn('id', $ids) 270 | ->offset($start) 271 | ->limit($limit) 272 | ->orderBy($order, $dir) 273 | ->get(); 274 | } else { 275 | $search = $request->input ('search.value'); 276 | 277 | $data = self::query()->select($columns); 278 | $data = $data->where(function ($q) use ($ids) { 279 | $q->whereIn('id', $ids); 280 | }); 281 | 282 | $data = $data->where(function ($q) use ($search){ 283 | foreach($this->getColumnNames() as $column){ 284 | $q->orWhere($column, 'LIKE', "%{$search}%"); 285 | } 286 | }); 287 | 288 | $data = $data 289 | ->offset($start) 290 | ->limit($limit) 291 | ->orderBy($order, $dir) 292 | ->get(); 293 | 294 | $totalFiltered = self:: 295 | whereIn('id', $ids) 296 | ->where(function ($q) use ($search) { 297 | foreach($this->getColumnNames() as $column){ 298 | $q->orWhere($column, 'LIKE', "%{$search}%"); 299 | } 300 | }) 301 | ->count(); 302 | } 303 | 304 | $columnStructure = $this->getTLAPTableStructure(); 305 | $data = $this->applyDataFilter($data->toArray(), $columnStructure); 306 | 307 | return response()->json([ 308 | 'draw' => intval($request->input('draw')), 309 | "recordsTotal"=> intval($totalData), 310 | "recordsFiltered"=> intval($totalFiltered), 311 | 'data' => $data 312 | ]); 313 | } 314 | 315 | public static function getModelIcon(): string 316 | { 317 | return self::$sidebarIcon ?? ''; 318 | } 319 | 320 | public function getActions(): string 321 | { 322 | return ''; 323 | } 324 | 325 | } 326 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for your application, as well as bundling up your JS files. 11 | | 12 | */ 13 | 14 | mix.webpackConfig({ 15 | resolve: { 16 | alias: { 17 | jquery: 'jquery/src/jquery' 18 | } 19 | } 20 | }); 21 | 22 | mix.autoload({ 23 | jquery: ['$', 'window.jQuery'] 24 | }); 25 | 26 | mix.config.fileLoaderDirs.fonts = 'public/fonts'; 27 | 28 | mix.js([ 29 | 'resources/js/tlap.js', 30 | ], 'public/js/tlap.js') 31 | .sass('resources/sass/tlap.scss', 'public/css/tlap.css'); 32 | --------------------------------------------------------------------------------