ronon
206
3
Laravel

Convert custom non eloquent model to json

Posted 5 months ago by ronon

I have a custom model, which is not filled with data from the database.

class MyModel {
        /**
          * @var string
      */
    protected $title;

    // Getter and setter for it
}

I also tried to extend it extend Model but i always get an empty response.

{
  0 :  [[],[],[],[]]
}

How can I get it to work that i can use return response()->json($data).

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.