Created
December 17, 2020 15:02
-
-
Save jongravois/fb6476d154a2efb2a50f8187d3bfa8ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Http\Livewire\Lots; | |
| use App\Models\ConsignmentBand; | |
| use App\Models\Project; | |
| use Livewire\Component; | |
| class BandEditor extends Component | |
| { | |
| public $pid; | |
| public $plot; | |
| public $newLow; | |
| public $newHigh; | |
| public $newPercent; | |
| protected $rules = [ | |
| 'newLow' => 'sometimes', | |
| 'newHigh' => 'sometimes', | |
| 'newPercent' => 'sometimes', | |
| ]; | |
| public function mount() | |
| { | |
| $project = Project::find($this->pid); | |
| $this->plot = $project->lot_code; | |
| } // end function | |
| public function render() | |
| { | |
| return view('livewire.lots.band-editor', [ | |
| 'bands' => ConsignmentBand::whereProjectId($this->pid)->orderby('low')->get() | |
| ]); | |
| } // end function | |
| public function addBand() | |
| { | |
| $newb = [ | |
| 'project_id' => $this->pid, | |
| 'consignment_code' => $this->plot, | |
| 'low' => (int)$this->newLow, | |
| 'high' => (int)$this->newHigh, | |
| 'percent' => $this->newPercent | |
| ]; | |
| // dd($newb); | |
| ConsignmentBand::create($newb); | |
| $this->reset(['newLow', 'newHigh', 'newPercent']); | |
| $this->emit('refreshLot'); | |
| } // end function | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment