https://github.com/miloudimohamed/datatables
Super useful package for managing your database from an admin panel.
https://github.com/miloudimohamed/datatables
datatables laravel
Last synced: 3 months ago
JSON representation
Super useful package for managing your database from an admin panel.
- Host: GitHub
- URL: https://github.com/miloudimohamed/datatables
- Owner: MiloudiMohamed
- License: mit
- Created: 2017-09-25T14:32:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T18:02:46.000Z (about 7 years ago)
- Last Synced: 2025-01-08T21:37:16.085Z (5 months ago)
- Topics: datatables, laravel
- Language: Vue
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DataTable
Useful package for managing your database from an admin panel.
## Installation### Step 1: Composer
From the command line, run:```bash
composer require devmi/datatables
```### Step 2: Service Provider
> If you're using laravel >5.5 skip to the next step.Open config/app.php and within the providers array:
```
Devmi\Datatables\DataTableServiceProvider::class
```### Step 3: Controller
For this package to function properly,
you must create a controller extends our base DataTableController.e.g:
```
php artisan make:controller UserController
```then, you must implement the abstract `builder` function
```php
use App\User;
use Devmi\Datatables\Controllers\DatatableController;class UserController extends DatatableController
{
public function builder()
{
return User::query();
}//...
}
```### Step 4: Route
Simply add resources route.
Open `routes/web.php` , add:
```
Route::resource('users', 'UserController');
```### Step 5: vendor puslish
Now you must publish the vue compenents and register it in order to use it.
```
php artisan vendor:publish --tag=devmi
```
open `resources/assets/js/app.js` and register the component
```
Vue.component('data-table', require('./vendor/devmi/DataTable.vue'));
```you find the file under `resources/assets/js/vendor/devmi/DataTable.vue` , **you customize it.**
## Usage
Now you can visit `www.domain.com/admin/users`> **'users'** is you table name.

- Repeat **step 3** & **step 4** for your other model.
### Notice
You must to install ES6 spread operator in order to use this package properly
```
npm install --save-dev babel-plugin-transform-object-rest-spread
```
then, create .babelrc file from you command line```
echo '{ "plugins": ["transform-object-rest-spread"] }' > .babelrc
```Now compile your asset running
```
npm run dev
```## Extra
#### Example:
You can override the following functions and variables for your need```php
/**
* Allows admin to add new record on database
*/$allowCreation: Bool
``````php
public function getDisplayableColumns()
{
return ['columns', 'you', 'need', 'to', 'display'];
}
``````php
public function getUpdatableColumns()
{
return ['updateable', 'columns'];
}
``````php
public function store(Request $request)
{
// Add validation for example
parent::store($request);
}
``````php
public function update($id, Request $request)
{
// Add validation for example
parent::update($id, $request);
}
```