Example #1
0
 /**
  * Return a new JSON response from the application.
  * Inject some headers
  *
  * @param  string|array  $data
  * @param  int    $status
  * @param  array  $headers
  * @return \Illuminate\Http\JsonResponse
  */
 public static function resourceJson($data = array(), $status = 200, array $headers = array())
 {
     $resource = new Resource($data);
     $etag = $resource->getEtag();
     if (!empty($etag)) {
         $headers['ETag'] = $etag;
     }
     unset($resource);
     return self::json($data, $status, $headers);
 }
Example #2
0
 /**
  * Return ETag based on collection of items
  *
  * @return string    md5 of all ETags
  */
 public function getEtags()
 {
     $etag = '';
     if ($this->data instanceof ArrayableInterface) {
         $this->data = $this->data->toArray();
     }
     foreach ($this->data as $item) {
         $item = new Resource($item);
         $etag .= $item->getEtag();
         unset($item);
     }
     return md5($etag);
 }