public function persistResource(RestfulModel $resource)
    {
        try {
            $resource->save();
        } catch (\Exception $e) {
            // Check for QueryException - if so, we may want to display a more meaningful message, or help with
            // development debugging
            if ($e instanceof QueryException) {
                if (stristr($e->getMessage(), 'duplicate')) {
                    throw new ConflictHttpException('The resource already exists: ' . $this->model);
                } elseif (Config::get('api.debug') === true) {
                    throw $e;
                }
            }

            // Default HTTP exception to use for storage errors
            $errorMessage = 'Unexpected error trying to store this resource.';

            if (Config::get('api.debug') === true) {
                $errorMessage .= ' ' . $e->getMessage();
            }

            throw new UnprocessableEntityHttpException($errorMessage);
        }

        return $resource;
    }
public function persistResource(RestfulModel $resource)
    {
        try {
            $resource->save();
        } catch (\Exception $e) {
            // Check for QueryException - if so, we may want to display a more meaningful message, or help with
            // development debugging
            if ($e instanceof QueryException) {
                if (stristr($e->getMessage(), 'duplicate')) {
                    throw new ConflictHttpException('The resource already exists: ' . $this->model);
                } elseif (Config::get('api.debug') === true) {
                    throw $e;
                }
            }

            // Default HTTP exception to use for storage errors
            $errorMessage = 'Unexpected error trying to store this resource.';

            if (Config::get('api.debug') === true) {
                $errorMessage .= ' ' . $e->getMessage();
            }

            throw new UnprocessableEntityHttpException($errorMessage);
        }

        return $resource;
    }
public function persistResource ( RestfulModel $ resource ) { try { $ resource -> save ( ) ; } catch ( \ Exception $ e ) { // Check for QueryException - if so, we may want to display a more meaningful message, or help with // development debugging if ( $ e instanceof QueryException ) { if ( stristr ( $ e -> getMessage ( ) , 'duplicate' ) ) { throw new ConflictHttpException ( 'The resource already exists: ' . $ this -> model ) ; } elseif ( Config :: get ( 'api.debug' ) === true ) { throw $ e ; } } // Default HTTP exception to use for storage errors $ errorMessage = 'Unexpected error trying to store this resource.' ; if ( Config :: get ( 'api.debug' ) === true ) { $ errorMessage .= ' ' . $ e -> getMessage ( ) ; } throw new UnprocessableEntityHttpException ( $ errorMessage ) ; } return $ resource ; }
Create model in the database

@param $model
@param $data
@return mixed
Create model in the database