sheenazien8 / hascrudactions
CRUD tirelessly 💤
Requires
- php: ^7.4
- illuminate/support: ^7.0.0
Requires (Dev)
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-12-29 07:03:45 UTC
README
Hascrudaction
This package allows you to build a CRUD with tiny Controller and keep the pattern are consitent.
Lifecycles
Requirements
- laravel 8.^ On Development
- laravel 7.^
- This package uses
yajra/laravel-datatables
(https://yajrabox.com/docs/laravel-datatables/master/quick-starter) for index table view under the hood, Please make sure you include this dependencies before using this library.
Installation
You can install the package via composer:
composer require sheenazien8/hascrudactions
Configuration
Laravel Configuration
php artisan vendor:publish --provider="Sheenazien8\Hascrudactions\HascrudactionsServiceProvider"
Register the provider class in config/app.php
"providers" => [ Sheenazien8\Hascrudactions\HascrudactionsServiceProvider::class, ]
Lumen Configuration
mkdir -p config cp vendor/sheenazien8/hascrudactions/config/config.php config/config.php
Basic Usage
First, Generate the Hascrud route with php artisan hascrudaction:make Employee
this command will be generate a few class and file views, Example.
- App\Http\Controllers\EmployeeController
- App\Http\Requests\Employee\.*
- App\Repositories\EmployeeRepository
- resources/views/employee/.*
And Setup the datatable.
Install Datatable Package and Setup
Install Composer
composer require yajra/laravel-datatables
Install Assets
yarn add datatables.net-bs4 datatables.net-buttons-bs4
Register datatables.net in resources js and css file
// Js file
require('bootstrap');
require('datatables.net-bs4');
require('datatables.net-buttons-bs4');
// Scss file
@import "~datatables.net-bs4/css/dataTables.bootstrap4.css";
@import "~datatables.net-buttons-bs4/css/buttons.bootstrap4.css";
Compile Assets
yarn dev / watch / prod
Next, you can add the path in routes/web.php
, edit file config in config/hascrudactions.php
for wrapper blade layouts and javascript views, add Traits HasLaTable
in Model Class Employee.
routes/web.php
Route::hascrud('employee');
config/hascrudactions.php
/** * Wrapper view, you can adjust static view like footer and header * put file in views path * layouts: * section: * javascript: */ 'wrapper' => [ 'layouts' => 'layouts.app', 'section' => 'content', 'javascript' => 'javascript' ]
app/Employee.php
use Sheenazien8\Hascrudactions\Traits\HasLaTable; class Employee extends Model { use HasLaTable; // }
And the last, you can define what columns you want to display in the index view in resources/views/employee/components/table.blade.php
, and then you must define what columns you want to add or edit in the model Employee
with $fillable
property and form view resources/views/employee/components/form.blade.php
, and also you can get the binding data from controller with the $data
variable name.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.