Skip to content

Commit

Permalink
merged conflict in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Daveawb committed Jun 16, 2014
2 parents be9119b + 676e6c3 commit 13286e0
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 99 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Laravel-Datatables
==================
[![Build Status](https://travis-ci.org/Daveawb/Laravel-Datatables.svg?branch=master)](https://travis-ci.org/Daveawb/Laravel-Datatables) [![Coverage Status](https://img.shields.io/coveralls/Daveawb/Laravel-Datatables.svg)](https://coveralls.io/r/Daveawb/Laravel-Datatables?branch=development)

[![Build Status](https://travis-ci.org/Daveawb/Laravel-Datatables.svg?branch=master)](https://travis-ci.org/Daveawb/Laravel-Datatables) [![Coverage Status](https://coveralls.io/repos/Daveawb/Laravel-Datatables/badge.png?branch=development)](https://coveralls.io/r/Daveawb/Laravel-Datatables?branch=development)

#Introduction
This project is aimed at anyone using the fantastic dataTables jQuery plugin written by [SpryMedia](http://sprymedia.co.uk/) and Laravel 4.1 or greater. It was written originally for dataTables 1.9.x, however since 1.10.x has now been released with a new API and data structure there will be updates to allow you to make use of the new syntax in the near future. If you haven't used datatables before check it out at [Datatables.net](http://datatables.net/).

Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
syntaxCheck="true"
>
<testsuites>
<testsuite name="exceptions">
<directory suffix=".php">./tests/exceptions</directory>
</testsuite>
<testsuite name="columns">
<directory suffix=".php">./tests/columns</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion src/Daveawb/Datatables/Columns/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function setInterpretationData($data)
* @return {String}
*/
public function interpret($field, &$data)
{
{
if (count($this->interpret) < 1 && is_null($this->closure))
return $data[$field];

Expand Down
9 changes: 6 additions & 3 deletions src/Daveawb/Datatables/DatatablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class DatatablesServiceProvider extends ServiceProvider {
*
* @var bool
*/
protected $defer = false;
protected $defer = true;

/**
* Register the service provider.
*
* @return void
* @return null
*/
public function register()
{
Expand All @@ -38,7 +38,10 @@ public function boot()
*/
public function provides()
{
return array();
return array(
"Daveawb\Datatables\Columns\Input\BaseInput",
"Daveawb\Datatables\Driver"
);
}

}
8 changes: 8 additions & 0 deletions src/Daveawb/Datatables/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ abstract class Driver {
* @var {Array}
*/
protected $config;

/**
* Instance of config class
* @var {Object} Illuminate\Config\Repository
*/
protected $repository;

/**
* Inject configuration options into the driver
Expand Down Expand Up @@ -76,6 +82,8 @@ public function factory(Factory $factory)
*/
public function setConfig(Repository $config)
{
$this->repository = $config;

$driverConfig = $this->getConfigName();

$cfgArray = $driverConfig === "laravel" ?
Expand Down
7 changes: 6 additions & 1 deletion src/Daveawb/Datatables/Drivers/Laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Query\Builder as Fluent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Contracts\ArrayableInterface;

use ErrorException;

Expand Down Expand Up @@ -100,7 +101,11 @@ public function config(array $config)
*/
public function get()
{
return $this->build()->get()->toArray();
$data = $this->build()->get();

return $data instanceof ArrayableInterface ?
$data->toArray() :
json_decode(json_encode($data), true);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Daveawb/Datatables/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ValidationException extends DatatablesException {
* of the validator as opposed to a string to save us some typing
* @param Validator $validator failed validator object
*/
public function __construct($validator)
public function __construct(Validator $validator)
{
$this->validator = $validator;
$this->messages = $validator->messages();
Expand Down
20 changes: 20 additions & 0 deletions tests/columns/expressions/AppendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,24 @@ public function testDataPassedIsSameInDataOutputFieldData()

$this->assertEquals("David Barker", $result);
}

public function testPlainEvaluationDoesNotIncludeField()
{
$data = array(
"first_name" => "David",
"last_name" => "Barker",
"username" => "daveawb",
"title" => "Mr"
);

$append = new Daveawb\Datatables\Columns\Expressions\Append(array(
"first_name",
), $data);

$result = $append->plain(array(
"last_name"," "
));

$this->assertEquals(" Barker", $result);
}
}
21 changes: 21 additions & 0 deletions tests/columns/expressions/PrependTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,25 @@ public function testDataPassedAsAnArrayIsEvaluatedAndAppended()
$this->assertEquals("prepended item: Mr prepended to David", $result);
}

public function testPlainEvaluationDoesNotReturnField()
{
$data = array(
"first_name" => "David",
"last_name" => "Barker",
"username" => "daveawb",
"title" => "Mr"
);

$combine = new Daveawb\Datatables\Columns\Expressions\Prepend(array(
"first_name",
"last_name"
), $data);

$result = $combine->plain(array(
array("prepended item:","title", "prepended to"), " "
));

$this->assertEquals("prepended item: Mr prepended to ", $result);
}

}

0 comments on commit 13286e0

Please sign in to comment.