Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Resource ID of 0 causes error #445

Closed
Closed
Labels
Milestone
@lindyhopchris

Description

I just ran into this, and the issue is the first ID in a legacy database was set to 0, so this was always returning true: https://github.com/cloudcreativity/laravel-json-api/blob/develop/src/Object/IdentifiableTrait.php#L78

Fixed it for now by modifying the Schema::getId() method in my resource:

	/**
	 * @param $resource
	 * the domain record being serialized.
	 *
	 * @return string
	 */
	public function getId( $resource ) 
	{
		$id = $resource->getRouteKey();
		if( empty( $id ) ) {
			$id = 1;
		}
		return (string) $id;
	}

Originally posted by @defunctl in #368 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /