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

toArray() public method

Convert the model instance to an array.
public toArray ( ) : array
return array
    public function toArray()
    {
        $attributes = $this->attributesToArray();
        return array_merge($attributes, $this->relationsToArray());
    }

Usage Example

Example #1
0
 public function toArray($user_id = null)
 {
     $array = parent::toArray();
     $array['supporter_counter'] = (int) Redis::get('supporter_counter:' . $this->id);
     $array['is_supported'] = (int) Redis::zscore('issue_supporters:' . $this->id, $user_id) > 0 ? 1 : 0;
     return $array;
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::toArray
Model