Last active
November 4, 2021 08:23
-
-
Save stojankukrika/de0d19d5f19b8006f0a41d9e5d8df463 to your computer and use it in GitHub Desktop.
Booking create
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
<div> | |
<form> | |
<label class="block text-sm"> | |
<span class="text-gray-700 dark:text-gray-400">{{__('site.bookings.date')}}</span> | |
<input | |
class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 | |
focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" | |
wire:model="search.date" type="date"/> | |
@error('date') | |
<div class="block w-full mt-1 text-sm text-red-600">{{ $message }}</div> | |
@enderror | |
</label> | |
<label class="block text-sm"> | |
<span class="text-gray-700 dark:text-gray-400">{{__('site.bookings.city_from')}}</span> | |
<select class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 | |
form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | |
wire:model="search.city_from_id"> | |
<option value="">{{__('site.bookings.select_city_from')}}</option> | |
@foreach($cities as $item) | |
<option value="{{$item->id}}">{{$item->name}}</option> | |
@endforeach | |
</select> | |
@error('city_from_id') | |
<div class="block w-full mt-1 text-sm text-red-600">{{ $message }}</div> | |
@enderror | |
</label> | |
<label class="block text-sm"> | |
<span class="text-gray-700 dark:text-gray-400">{{__('site.bookings.city_to')}}</span> | |
<select class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 | |
form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | |
wire:model="search.city_to_id"> | |
<option value="">{{__('site.bookings.select_city_to')}}</option> | |
@foreach($cities as $item) | |
<option value="{{$item->id}}">{{$item->name}}</option> | |
@endforeach | |
</select> | |
@error('city_to_id') | |
<div class="block w-full mt-1 text-sm text-red-600">{{ $message }}</div> | |
@enderror | |
</label> | |
</form> | |
</div> |
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; | |
use App\Models\City; | |
use Illuminate\Support\Facades\DB; | |
use Livewire\Component; | |
class BookingCreate extends Component | |
{ | |
public $cities; | |
public $search; | |
public function mount() | |
{ | |
$this->search = ['date' => null, 'city_from_id' => null, 'city_to_id' => null]; | |
$this->cities = City::join('countries', 'countries.id', '=', 'cities.country_id') | |
->select('cities.id', DB::raw('CONCAT(cities.name, " - ", countries.nicename) as name')) | |
->get(); | |
} | |
public function render() | |
{ | |
return view('livewire.booking-create'); | |
} | |
public function updatedSearchDate($value) | |
{ | |
$this->test(); | |
} | |
public function updatedSearchCityFromId($value) | |
{ | |
$this->test(); | |
} | |
public function updatedSearchCityToId($value) | |
{ | |
$this->test(); | |
} | |
/*public function updatedSearch($value) | |
{ | |
$this->test(); | |
}*/ | |
public function test() | |
{ | |
if (isset($this->search['date']) && $this->search['date'] != null && | |
isset($this->search['city_from_id']) && $this->search['city_from_id'] != null && | |
isset($this->search['city_to_id']) && $this->search['city_to_id'] != null) { | |
dump('do something nice'); | |
} else { | |
dump($this->search['date']??'DATE'); | |
dump($this->search['city_from_id']??'CITY FROM'); | |
dump($this->search['city_to_id']??'CITY TO'); | |
dump('do something not nice'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment