You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.0 KiB
PHTML
43 lines
1.0 KiB
PHTML
3 months ago
|
<?php
|
||
|
|
||
|
namespace App\Livewire;
|
||
|
|
||
|
use App\Enums\OrderStatus;
|
||
|
use App\Enums\OrderType;
|
||
|
use App\Models\Customer;
|
||
|
use Illuminate\Database\Eloquent\Collection;
|
||
|
use Illuminate\Support\Carbon;
|
||
|
use Livewire\Component;
|
||
|
|
||
|
class CreateOrder extends Component
|
||
|
{
|
||
|
public Collection $customers;
|
||
|
|
||
|
public string $selectedCustomer;
|
||
|
|
||
|
public $contacts;
|
||
|
|
||
|
public function mount(Collection $customers)
|
||
|
{
|
||
|
$this->customers = $customers;
|
||
|
$this->contacts = $customers->first()->contacts;
|
||
|
}
|
||
|
|
||
|
public function getContacts()
|
||
|
{
|
||
|
$this->contacts = Customer::find($this->selectedCustomer)->contacts;
|
||
|
}
|
||
|
|
||
|
public function render()
|
||
|
{
|
||
|
return view('livewire.create-order', [
|
||
|
'contacts' => $this->contacts,
|
||
|
'order_types' => OrderType::cases(),
|
||
|
'order_status' => OrderStatus::cases(),
|
||
|
'customers' => $this->customers,
|
||
|
'today' => Carbon::today()->format('Y-m-d'),
|
||
|
'due_default' => Carbon::today()->addDay(10)->format('Y-m-d'),
|
||
|
]);
|
||
|
}
|
||
|
}
|