src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
public function store(Request $request)
    {
        $createResource = $this->createResourceCallable();
        $resource = new CreateResource($this->serializer);

        $model = $this->getDataModel();
        $data = (array) $request->get('data');
        if (array_key_exists('attributes', $data) && $model->timestamps) {
            $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString();
            $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString();
        }

        return $this->addHeaders(
          $resource->get($data, get_class($this->getDataModel()), $createResource)
        );
    }
public function store(Request $request)
    {
        $createResource = $this->createResourceCallable();
        $resource = new CreateResource($this->serializer);

        $model = $this->getDataModel();
        $data = (array) $request->get('data');
        if (array_key_exists('attributes', $data) && $model->timestamps) {
            $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString();
            $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString();
        }

        return $this->addHeaders(
          $resource->get($data, get_class($this->getDataModel()), $createResource)
        );
    }
public function store ( Request $ request ) { $ createResource = $ this -> createResourceCallable ( ) ; $ resource = new CreateResource ( $ this -> serializer ) ; $ model = $ this -> getDataModel ( ) ; $ data = ( array ) $ request -> get ( 'data' ) ; if ( array_key_exists ( 'attributes' , $ data ) && $ model -> timestamps ) { $ data [ 'attributes' ] [ $ model :: CREATED_AT ] = Carbon :: now ( ) -> toDateTimeString ( ) ; $ data [ 'attributes' ] [ $ model :: UPDATED_AT ] = Carbon :: now ( ) -> toDateTimeString ( ) ; } return $ this -> addHeaders ( $ resource -> get ( $ data , get_class ( $ this -> getDataModel ( ) ) , $ createResource ) ) ; }
Post Action.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response
Post Action .