Illuminate\Database\Eloquent\Model::getKey PHP Method

getKey() public method

Get the value of the model's primary key.
public getKey ( ) : mixed
return mixed
    public function getKey()
    {
        return $this->getAttribute($this->getKeyName());
    }

Usage Example

示例#1
5
 /**
  * Add a tenant to scope by.
  *
  * @param string|Model $tenant
  * @param mixed|null   $id
  */
 public function addTenant($tenant, $id = null)
 {
     if (func_num_args() == 1) {
         $id = $tenant->getKey();
     }
     $this->tenants->put($this->getTenantKey($tenant), $id);
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::getKey
Model