Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I get appended columns in model to array?

How can I get appended columns in model to array?

$ticket = Ticket::create([
  'assigned_user_id' => $request->assigned_user_id,
  'creator_id' => $request->creator_id,
  'description' => $request->description,
  'type' => $request->type,
  'status' => Ticket::CREATED,
]);
   
flash(__('tickets.ticket_created_successfully'))->success();
    
$data = $ticket->refresh()->toArray();
return $data;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Change $ticket>refresh()->toArray(); to $ticket->toArray(); I don’t think you need to refresh your model in this case.
Read more about serializing to array here
in the official docs of Laravel.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading