Skip to content

Commit 4fb11ea

Browse files
author
bllim
committed
creation
0 parents  commit 4fb11ea

File tree

14 files changed

+711
-0
lines changed

14 files changed

+711
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
7+
before_script:
8+
- curl -s http://getcomposer.org/installer | php
9+
- php composer.phar install --dev
10+
11+
script: phpunit

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
## Datatables Bundle for Laravel 4
2+
3+
**About**
4+
5+
This bundle is created to handle server-side works of DataTables Jquery Plugin (http://datatables.net) by using Eloquent ORM or Fluent Query Builder.
6+
7+
### Feature Overview
8+
- Supporting Eloquent ORM and Fluent Query Builder
9+
- Adding or editing content of columns and removing columns
10+
- Templating new or current columns via Blade Template Engine
11+
12+
13+
### Installation
14+
15+
Add the `bllim/datatables` under the `require` key after that run the `composer update`.
16+
17+
{
18+
"require": {
19+
"laravel/framework": "4.0.*",
20+
...
21+
"bllim/datatables": "*"
22+
}
23+
...
24+
}
25+
26+
Composer will download the package. After package downloaded, open "app/config/app.php" and edit like below:
27+
28+
'providers' => array(
29+
...
30+
'Bllim\Datatables\DatatablesServiceProvider',
31+
),
32+
33+
34+
35+
'aliases' => array(
36+
...
37+
'Datatables' => 'Bllim\Datatables\Datatables',
38+
),
39+
40+
41+
### Usage
42+
43+
It is very simple to use this bundle. Just create your own fluent query object or eloquent object without getting results (that means don't use get(), all() or similar methods) and give it to Datatables.
44+
You are free to use all Eloquent ORM and Fluent Query Builder features.
45+
46+
It is better, you know these:
47+
- When you use select method on Eloquent or Fluent Query, you choose columns
48+
- You can easily edit columns by using edit_column($column,$content)
49+
- You can remove any column by using remove_column($column) method
50+
- You can add columns by using add_column($column_name, $content)
51+
- You can use Blade Template Engine in your $content values
52+
- The name of columns is set by returned array.
53+
- That means, for 'posts.id' it is 'id' and also for 'owner.name as ownername' it is 'ownername'
54+
55+
56+
### Examples
57+
58+
**Example 1:**
59+
60+
$posts = Post::select(array('posts.id','posts.name','posts.created_at','posts.status'));
61+
62+
return Datatables::of($posts)->make();
63+
64+
65+
**Example 2:**
66+
67+
$place = Place::left_join('owner','places.author_id','=','owner.id')
68+
->select(array('places.id','places.name','places.created_at','owner.name as ownername','places.status'));
69+
70+
71+
return Datatables::of($place)
72+
->add_column('operations','<a href="{{ URL::to_route( \'admin.post\', array( \'edit\',$id )) }}">edit</a>
73+
<a href="{{ URL::to_route( \'admin.post\', array( \'delete\',$id )) }}">delete</a>
74+
')
75+
->edit_column('status','@if($status)
76+
Active
77+
@else
78+
Passive
79+
@endif')
80+
// you can also give a function as parameter to edit_column and add_column instead of blade string
81+
->edit_column('ownername','Author of this post is {{ $ownername }}')
82+
->remove_column('id')
83+
->make();
84+
85+
**Notice:** If you use double quotes while giving content of add_column or edit_column, you should escape variables with backslash (\) else you get error. For example:
86+
87+
edit_column('id',"- {{ \$id }}") .
88+
89+
90+
**License:** Licensed under the MIT License

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "bllim/datatables",
3+
"version" : "1.0.0",
4+
"description": "Server-side handler of DataTables Jquery Plugin for Laravel 4",
5+
"keywords" : ["laravel4","laravel","datatables","datatable","datatables jquery plugin"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Bilal Gultekin",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php": ">=5.3.0",
15+
"illuminate/support": "4.0.x",
16+
"illuminate/view": "4.0.x",
17+
"illuminate/filesystem": "4.0.x"
18+
},
19+
"autoload": {
20+
"classmap": [
21+
"src/migrations"
22+
],
23+
"psr-0": {
24+
"Bllim\\Datatables": "src/"
25+
}
26+
},
27+
"minimum-stability": "dev"
28+
}

phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Package Test Suite">
15+
<directory suffix=".php">./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>

public/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)