Created
December 6, 2018 09:11
-
-
Save thiagomarini/3dd27b583c37e8ac93358afe55adb565 to your computer and use it in GitHub Desktop.
Data Fetcher Example
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
<?php | |
namespace Weengs\DataFetcher\Collections\Admin; | |
use Weengs\DataFetcher\DataFetcherInterface; | |
use Weengs\Models\WmsUser\App; | |
class ListApps implements DataFetcherInterface | |
{ | |
/** | |
* @param array $params | |
* @return array | |
*/ | |
public function fetch(array $params): array | |
{ | |
$apps = App::orderBy('name')->get(); | |
return [ | |
'apps' => $apps->map(function (App $app) { | |
return [ | |
'id' => $app->id, | |
'name' => $app->name, | |
'description' => $app->description, | |
'created_at' => $app->created_at->format('d M Y H:i'), | |
'updated_at' => $app->updated_at->format('d M Y H:i'), | |
]; | |
}) | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment