Home > Net >  How can I get appended columns in model to array?
How can I get appended columns in model to array?

Time:03-23

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;

CodePudding user response:

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.

  • Related