Skip to content

Instantly share code, notes, and snippets.

@jongravois
Created December 17, 2020 15:02
Show Gist options
  • Select an option

  • Save jongravois/fb6476d154a2efb2a50f8187d3bfa8ff to your computer and use it in GitHub Desktop.

Select an option

Save jongravois/fb6476d154a2efb2a50f8187d3bfa8ff to your computer and use it in GitHub Desktop.
<?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