transaction_type) && $this->transaction_type == 'SELL') { return __('Sale Price'); } return __('Cost Basis'); } // methods public function mount() { if (isset($this->transaction)) { $this->symbol = $this->transaction->symbol; $this->transaction_type = $this->transaction->transaction_type; $this->date = $this->transaction->date->format('Y-m-d'); $this->quantity = $this->transaction->quantity; $this->cost_basis = $this->transaction_type == 'SELL' ? $this->transaction->sale_price : $this->transaction->cost_basis; } else { $this->transaction_type = 'BUY'; $this->date = now()->format('Y-m-d'); } } public function update() { $this->transaction->update($this->validate()); // $this->transaction->owner_id = auth()->user()->id; $this->transaction->save(); $this->success(__('Transaction updated'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id])); } public function save() { $transaction = $this->portfolio->transactions()->create($this->validate()); $transaction->save(); $this->success(__('Transaction created'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id])); } public function delete() { $this->transaction->delete(); $this->success(__('Transaction deleted'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id])); } }; ?>