Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Concerns/WithCreateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

/**
* @template TModel of Model
*/
trait WithCreateAction
{
/**
Expand Down Expand Up @@ -80,11 +83,18 @@ protected function createMessages(): array
return [];
}

/**
* @param TModel $model
*/
public function creating(Model $model, array $data): array
{
return $data;
}

/**
* @param TModel $model
* @return TModel
*/
public function created(Model $model, array $data): Model
{
return $model;
Expand Down
10 changes: 10 additions & 0 deletions src/Concerns/WithEditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

/**
* @template TModel of Model
*/
trait WithEditAction
{
/**
Expand Down Expand Up @@ -81,11 +84,18 @@ protected function editMessages(): array
return [];
}

/**
* @param TModel $model
*/
public function updating(Model $model, array $data): array
{
return $data;
}

/**
* @param TModel $model
* @return TModel
*/
public function updated(Model $model, array $data): Model
{
return $model;
Expand Down
10 changes: 10 additions & 0 deletions src/Concerns/WithRemoveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

/**
* @template TModel of Model
*/
trait WithRemoveAction
{
/**
Expand Down Expand Up @@ -83,11 +86,18 @@ protected function removeMessages(): array
return [];
}

/**
* @param TModel $model
*/
public function deleting(Model $model, array $data): array
{
return $data;
}

/**
* @param TModel $model
* @return TModel
*/
public function deleted(Model $model, array $data): Model
{
return $model;
Expand Down
6 changes: 6 additions & 0 deletions src/DataTablesEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
*/
abstract class DataTablesEditor
{
/** @use \Yajra\DataTables\Concerns\WithCreateAction<TModel> */
use Concerns\WithCreateAction;

/** @use \Yajra\DataTables\Concerns\WithEditAction<TModel> */
use Concerns\WithEditAction;

use Concerns\WithForceDeleteAction;

/** @use \Yajra\DataTables\Concerns\WithRemoveAction<TModel> */
use Concerns\WithRemoveAction;
use Concerns\WithRestoreAction;
use Concerns\WithUploadAction;
Expand Down