/**
  * Create or update a note
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function createNote($orderNumber, Request $request)
 {
     $navCode = $request->input('navCode');
     $note = $request->input('note');
     $note = Note::createOrUpdate($orderNumber, $note);
     event(with(new OrderNoteChangedEvent($orderNumber, $navCode)));
     event(with(new OrderChangedEvent($orderNumber)));
     return $this->success($note);
 }
示例#2
0
 /**
  * Create or update a note
  *
  * @param array $orderNumber
  * @param $note
  * @return static
  */
 public static function createOrUpdate($orderNumber, $text)
 {
     $note = Note::where('order_number', $orderNumber)->first();
     if (!$note) {
         $note = new static();
         $note->order_number = $orderNumber;
         $note->note = $text;
         $note->created_at = Carbon::now()->toDateTimeString();
     } else {
         $note->note = $text;
     }
     $note->updated_at = Carbon::now()->toDateTimeString();
     $note->save();
     return $note;
 }
 public function importOrderNotes()
 {
     $notes = DB::connection('old')->table('order_notes')->get();
     foreach ($notes as $note) {
         $newNote = new Note();
         $newNote->order_number = $note->order_number;
         $newNote->note = $note->note;
         $newNote->created_at = $note->date;
         $newNote->updated_at = $note->date;
         $newNote->save();
     }
 }
示例#4
0
 /**
  * Get the note for the order
  */
 public function getNote()
 {
     $this->note = Note::where('order_number', $this->number)->first();
 }