} } } // subsequent filters will be using the $userIds variable if (!empty($userIds) && !empty($skilbaseids)) { $userIds = array_intersect($userIds, $skilbaseids); } elseif (!empty($skilbaseids)) { $userIds = $skilbaseids; } Log::info($userIds); $users = \Motibu\Models\Candidate::with('user')->whereIn('user_id', $userIds)->paginate(); $fractal = new \League\Fractal\Manager(); $collection = $users->getCollection(); $resource = new \League\Fractal\Resource\Collection($users, new \Motibu\Transformers\CandidateTransformer()); $resource->setPaginator(new \League\Fractal\Pagination\IlluminatePaginatorAdapter($users)); $rootScope = $fractal->createData($resource); return \Response::json(['professionals' => $rootScope->toArray()]); }); Route::post('/place_order', function () { // TODO: here's where you do the stripe parts // simply adding a subscription to an user return \Response::json(['success' => true]); }); }); /** * Base URL will be api.motibu.com * Api Version Prefix */ Route::group(array('prefix' => 'v1', 'before' => ['oauth.add_auth_header', 'oauth', 'oauth.authenticate', 'auth.permissions'], 'after' => ['allow_cross_origin']), function () { Route::get('messages/{user_1_id}/{user_2_id}', function ($user1, $user2) { if (Auth::user()->id !== $user1 && Auth::user()->id !== $user2) {
/** * @param int $id * @return mixed */ public function show($id) { if ($item = $this->repository->find($id)) { $resource = new Item($item, $this->getTransformer(), $item->getTable()); return $this->manager->createData($resource)->toJson(); } return null; }
/** * * @param \League\Fractal\Resource\ResourceInterface $fractal */ protected function writeJson($resource, $status = 200) { $fractal = new \League\Fractal\Manager(); $this->app->response->setStatus($status); $this->app->response->headers->set('Content-Type', 'application/json'); $this->app->contentType('application/json; charset=utf-8'); $fractalArray = $fractal->createData($resource)->toArray(); $this->app->response->setBody(json_encode($fractalArray, JSON_UNESCAPED_SLASHES)); }
/** * @param $provider * @param $productId * @return array */ public function productAction($provider, $productId) { $result = (new $provider())->product($productId); $fractal = new \League\Fractal\Manager(); $class = ucfirst($provider) . 'Transformer'; $transformer = new $class(); $resource = new \League\Fractal\Resource\Item($result, $transformer); return $fractal->createData($resource)->toArray(); }
public function updateProductAction($id) { list($provider, $productId) = explode('-', Input::get('token')); $result = (new $provider())->product($productId); $fractal = new \League\Fractal\Manager(); $class = ucfirst($provider) . 'Transformer'; $transformer = new $class(); $resource = new \League\Fractal\Resource\Item($result, $transformer); $data = $fractal->createData($resource)->toArray()['data']; $product = Product::find($id); $product->product_id = $productId; $product->title = $data['title']; $product->description = $data['description']; $product->provider = $provider; $product->price = $data['price']; $product->target = $data['target']; $product->save(); return Redirect::route('products'); }
function fractal_item_array($model, $transformer) { $manager = new League\Fractal\Manager(); $item = new League\Fractal\Resource\Item($model, $transformer); return $manager->createData($item)->toArray(); }
function fractal_item_array($model, $transformer, $includes = null) { $manager = new League\Fractal\Manager(); if ($includes !== null) { $manager->parseIncludes($includes); } $item = new League\Fractal\Resource\Item($model, $transformer); return $manager->createData($item)->toArray(); }
function fractal_api_serialize_collection($model, $transformer, $includes = null) { $manager = new League\Fractal\Manager(); if ($includes !== null) { $manager->parseIncludes($includes); } $manager->setSerializer(new App\Serializers\ApiSerializer()); // we're using collection instead of item here, so we can peak at the items beforehand $collection = new League\Fractal\Resource\Collection($model, $transformer); return $manager->createData($collection)->toArray(); }
function getTransformedItem($data, League\Fractal\TransformerAbstract $transformer, $resourceKey = null) { if (empty($data)) { return null; } $item = new League\Fractal\Resource\Item($data, $transformer, $resourceKey); $manager = new League\Fractal\Manager(); $output = $manager->createData($item)->toArray(); return $output['data']; }
function json_collection($model, $transformer, $includes = null) { $manager = new League\Fractal\Manager(); if ($includes !== null) { $manager->parseIncludes($includes); } $manager->setSerializer(new App\Serializers\ApiSerializer()); // da bess if (is_string($transformer)) { $transformer = 'App\\Transformers\\' . str_replace('/', '\\', $transformer) . 'Transformer'; $transformer = new $transformer(); } // we're using collection instead of item here, so we can peek at the items beforehand $collection = new League\Fractal\Resource\Collection($model, $transformer); return $manager->createData($collection)->toArray(); }