generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from hamidrezarj/datatable_test
wrote tests for different search functions and datatypes
- Loading branch information
Showing
19 changed files
with
896 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace HamidRrj\LaravelDatatable\Database\Factories; | ||
|
||
use HamidRrj\LaravelDatatable\Tests\Models\Post; | ||
use HamidRrj\LaravelDatatable\Tests\Models\User; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
|
||
class PostFactory extends Factory | ||
{ | ||
protected $model = Post::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'title' => $this->faker->name(), | ||
'description' => $this->faker->text(), | ||
'user_id' => User::factory(), | ||
]; | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('posts', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('user_id') | ||
->constrained(); | ||
$table->string('title'); | ||
$table->text('description'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,28 @@ class Datatable | |
{ | ||
/** | ||
* Extracts data from request, passes to datatable service and prepares data for response. | ||
* | ||
* @param Model|Builder $mixed | ||
* @param array $requestParameters | ||
* @param array $allowedFilters | ||
* @param array $allowedRelations | ||
* @param array $allowedSortings | ||
* @param array $allowedSelects | ||
* @return array | ||
* @throws InvalidParameterInterface if input parameters are invalid. | ||
*/ | ||
public function run( | ||
Check failure on line 25 in src/Facades/Datatable.php GitHub Actions / phpstan
|
||
Model|Builder $mixed, | ||
array $requestParameters, | ||
array $allowedFilters = [], | ||
array $allowedRelations = [], | ||
array $allowedSortings = [], | ||
array $allowedSelects = [] | ||
): array { | ||
array $requestParameters, | ||
array $allowedFilters = [], | ||
array $allowedRelations = [], | ||
array $allowedSortings = [], | ||
array $allowedSelects = [] | ||
): array | ||
{ | ||
|
||
$filters = json_decode($requestParameters['filters']); | ||
$sorting = json_decode($requestParameters['sorting']); | ||
$rels = array_key_exists('rels', $requestParameters) ? $requestParameters['rels'] : []; | ||
$rels = array_key_exists('rels', $requestParameters) ? $requestParameters['rels'] : array(); | ||
|
||
$dataTableInput = new DataTableInput( | ||
$requestParameters['start'], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ class Sort | |
private static SortingValidator $sortingValidator; | ||
|
||
/** | ||
* @param string $id | ||
* @param bool $desc | ||
* @param array $allowedSortings | ||
* @throws InvalidSortingException | ||
*/ | ||
public function __construct( | ||
Check failure on line 17 in src/Sort/Sort.php GitHub Actions / phpstan
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.