Skip to content

custom relationships #408

@ehsan5

Description

@ehsan5

hi
I want to have this url
api/v1/users/124/sender-transactions

and I definde custom relationship in App\User.php

 public function getSenderTransactions2Attribute()
    {
        $transactions = $this->transactions()->where("status",Enum::TRANSACTION_SUCCEED)->get();
        $this->senderRequests->each(function ($request) use (&$transactions) {
            if ($request->status == Request::STATUS_DONE || $request->status == Request::STATUS_COMPLETE) {
                $transaction = new Transaction();
                $transaction->price_daryafti = $request->finalPrice;
                $transaction->date = $request->miladiDate;
                $transaction->id = Enum::REQUEST."-".$request->name;
                $transaction->port = Enum::REQUEST;
                $transactions->push($transaction);

            }
        });
        return $transactions;
    }

and in users adapter :

protected function senderTransactions()
    {
        return $this->hasMany();
    }

Now I get this error
"message": "JSON API relation HasMany cannot be used for an Eloquent Collection relation.",

I worked befor in previous version of your library
Can you help me?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions