Book a viewing public websiteliberu-real-estate/real-estate-laravel#28
Book a viewing public website
liberu-real-estate/real-estate-laravel#28
> > >
✓ Completed in 8 minutes, 5 months ago using GPT-4  •  Book a call  •  Report a bug
Progress
  Create
app/Http/Livewire/PropertyBooking.php
f58e7bc
 1<?php
2
3namespace App\Http\Livewire;
4
5use Livewire\Component;
6use App\Models\Property;
7use App\Models\Booking;
8use Carbon\Carbon;
9
10class PropertyBooking extends Component
11{
12 public $propertyId;
13 public $selectedDate;
14 public $availableDates = [];
15
16 protected $rules = [
17 'selectedDate' => 'required|date|after_or_equal:today',
18 ];
19
20 public function mount($propertyId)
21 {
22 $this->propertyId = $propertyId;
23 // Assuming a method exists in the Property model to get available dates
24 $this->availableDates = Property::find($this->propertyId)->getAvailableDates();
25 }
26
27 public function selectDate($date)
28 {
29 $this->selectedDate = $date;
30 $this->validate();
31 }
32
33 public function bookViewing()
34 {
35 $this->validate();
36
37 Booking::create([
38 'property_id' => $this->propertyId,
39 'date' => new Carbon($this->selectedDate),
40 'user_id' => auth()->id(),
41 ]);
42
43 session()->flash('message', 'Booking successful for ' . $this->selectedDate);
44 $this->reset('selectedDate');
45 }
46
47 public function render()
48 {
49 return view('livewire.property-booking', [
50 'availableDates' => $this->availableDates,
51 ]);
52 }
53}
54
- Create a new Livewire component named PropertyBooking in the app/Http/Livewire directory.
- This component will handle the logic for booking property viewings, including displaying a calendar for users to select available dates.
- Use the FullCalendar library (or a similar library compatible with Livewire) for the calendar functionality, ensuring it's integrated within the Livewire component for dynamic interactions.
- Implement methods within the PropertyBooking component to handle the booking process, including date selection, validation, and saving the booking information to the database.
- Ensure the component renders a view file located at resources/views/livewire/property-booking.blade.php, which will contain the HTML structure and Livewire directives for the booking form and calendar.
  Run GitHub Actions for
app/Http/Livewire/PropertyBooking.phpÂ
Ran GitHub Actions for f58e7bc88cc6aff47737380697fe6ba39c57a9a5:
  Create
resources/views/livewire/property-booking.blade.php
7e61b76
 1<div>
2 @if (session()->has('message'))
3 <div class="alert alert-success">
4 {{ session('message') }}
5 </div>
6 @endif
7
8 <form wire:submit.prevent="bookViewing">
9 <div class="form-group">
10 <label for="bookingDate">Select a Date</label>
11 <input type="date" id="bookingDate" class="form-control" wire:model="selectedDate" min="{{ now()->toDateString() }}">
12 @error('selectedDate') <span class="error">{{ $message }}</span> @enderror
13 </div>
14
15 <div class="form-group">
16 <label for="userName">Name</label>
17 <input type="text" id="userName" class="form-control" wire:model="userName">
18 @error('userName') <span class="error">{{ $message }}</span> @enderror
19 </div>
20
21 <div class="form-group">
22 <label for="userContact">Contact Information</label>
23 <input type="text" id="userContact" class="form-control" wire:model="userContact">
24 @error('userContact') <span class="error">{{ $message }}</span> @enderror
25 </div>
26
27 <div class="form-group">
28 <label for="notes">Additional Notes</label>
29 <textarea id="notes" class="form-control" wire:model="notes"></textarea>
30 @error('notes') <span class="error">{{ $message }}</span> @enderror
31 </div>
32
33 <button type="submit" class="btn btn-primary">Book Viewing</button>
34 </form>
35</div>
36
- Create the Blade template for the PropertyBooking Livewire component.
- Include a calendar UI component for selecting the booking date.
- Add a form for any additional booking information required, such as the user's name, contact information, and any notes.
- Utilize Livewire directives for binding form inputs to the Livewire component's properties and handling form submission.
  Run GitHub Actions for
resources/views/livewire/property-booking.blade.phpÂ
Ran GitHub Actions for 7e61b7654febae071cabcd3068c375f970156ce9:
  ModifyChanged
app/Http/Livewire/PropertyList.php:25-29Â
Changed app/Http/Livewire/PropertyList.php
in eb9097c
   Â
30 | ]); | 30 | ]); |
31 | } | 31 | } |
32 | } | 32 | } |
33 | ])->with(['bookingLink' => function($property) { | ||
34 | return route('livewire.property-booking', ['propertyId' => $property->id]); | ||
35 | }]); |
- Modify the render method of the PropertyList component to include a link or button for each property that allows users to book a viewing.
- This link or button should direct users to the PropertyBooking component, passing the property ID as a parameter to the component for booking.
Modified file with Assistant API
  Run GitHub Actions for
app/Http/Livewire/PropertyList.phpÂ
Ran GitHub Actions for eb9097cc51037fa82f64158525e7ba59611253bc:
  ModifyChanged
routes/web.php:21-24Â
Changed routes/web.php
in 21048cd
   Â
24 | Route::post('/bookings', [\App\Http\Controllers\BookingController::class, 'store']); | 24 | Route::post('/bookings', [\App\Http\Controllers\BookingController::class, 'store']); |
25 | Route::put('/bookings/{booking}', [\App\Http\Controllers\BookingController::class, 'update']); | 25 | Route::put('/bookings/{booking}', [\App\Http\Controllers\BookingController::class, 'update']); |
26 | Route::get('/bookings', [\App\Http\Controllers\BookingController::class, 'index']); | 26 | Route::get('/bookings', [\App\Http\Controllers\BookingController::class, 'index']); |
27 | Route::get('/properties/{property}/book', \App\Http\Livewire\PropertyBooking::class)->name('property.book'); |
- Add a new route for the PropertyBooking Livewire component to handle URLs for booking property viewings.
- The route should be defined to capture property IDs as a parameter and render the PropertyBooking component, allowing users to book viewings for specific properties.
- Example route definition: Route::get('/properties/{property}/book', \App\Http\Livewire\PropertyBooking::class)->name('property.book');
Modified file with Assistant API
  Run GitHub Actions for
routes/web.phpÂ
Ran GitHub Actions for 21048cda3e6fb6ac309f047afe8675d7ad09f660:
Plan
This is based on the results of the Planning step. The plan may expand from failed GitHub Actions runs.
  Create
app/Http/Livewire/PropertyBooking.php
f58e7bc
 1<?php
2
3namespace App\Http\Livewire;
4
5use Livewire\Component;
6use App\Models\Property;
7use App\Models\Booking;
8use Carbon\Carbon;
9
10class PropertyBooking extends Component
11{
12 public $propertyId;
13 public $selectedDate;
14 public $availableDates = [];
15
16 protected $rules = [
17 'selectedDate' => 'required|date|after_or_equal:today',
18 ];
19
20 public function mount($propertyId)
21 {
22 $this->propertyId = $propertyId;
23 // Assuming a method exists in the Property model to get available dates
24 $this->availableDates = Property::find($this->propertyId)->getAvailableDates();
25 }
26
27 public function selectDate($date)
28 {
29 $this->selectedDate = $date;
30 $this->validate();
31 }
32
33 public function bookViewing()
34 {
35 $this->validate();
36
37 Booking::create([
38 'property_id' => $this->propertyId,
39 'date' => new Carbon($this->selectedDate),
40 'user_id' => auth()->id(),
41 ]);
42
43 session()->flash('message', 'Booking successful for ' . $this->selectedDate);
44 $this->reset('selectedDate');
45 }
46
47 public function render()
48 {
49 return view('livewire.property-booking', [
50 'availableDates' => $this->availableDates,
51 ]);
52 }
53}
54
  Run GitHub Actions for
app/Http/Livewire/PropertyBooking.phpÂ
  Create
resources/views/livewire/property-booking.blade.php
7e61b76
 1<div>
2 @if (session()->has('message'))
3 <div class="alert alert-success">
4 {{ session('message') }}
5 </div>
6 @endif
7
8 <form wire:submit.prevent="bookViewing">
9 <div class="form-group">
10 <label for="bookingDate">Select a Date</label>
11 <input type="date" id="bookingDate" class="form-control" wire:model="selectedDate" min="{{ now()->toDateString() }}">
12 @error('selectedDate') <span class="error">{{ $message }}</span> @enderror
13 </div>
14
15 <div class="form-group">
16 <label for="userName">Name</label>
17 <input type="text" id="userName" class="form-control" wire:model="userName">
18 @error('userName') <span class="error">{{ $message }}</span> @enderror
19 </div>
20
21 <div class="form-group">
22 <label for="userContact">Contact Information</label>
23 <input type="text" id="userContact" class="form-control" wire:model="userContact">
24 @error('userContact') <span class="error">{{ $message }}</span> @enderror
25 </div>
26
27 <div class="form-group">
28 <label for="notes">Additional Notes</label>
29 <textarea id="notes" class="form-control" wire:model="notes"></textarea>
30 @error('notes') <span class="error">{{ $message }}</span> @enderror
31 </div>
32
33 <button type="submit" class="btn btn-primary">Book Viewing</button>
34 </form>
35</div>
36
  Run GitHub Actions for
resources/views/livewire/property-booking.blade.phpÂ
  Run GitHub Actions for
app/Http/Livewire/PropertyList.phpÂ
  Modify
routes/web.php:21-24Â
  Run GitHub Actions for
routes/web.phpÂ
Code Snippets Found
This is based on the results of the Searching step.
app/Http/Livewire/PropertyList.php:0-31
 1<?php
2
3namespace App\Http\Livewire;
4
5use Livewire\Component;
6use App\Models\Property;
7
8class PropertyList extends Component
9{
10 public $properties;
11 public $search = '';
12
13 public function mount()
14 {
15 $this->properties = Property::all();
16 }
17
18 public function updatedSearch()
19 {
20 $this->properties = Property::where('title', 'like', '%' . $this->search . '%')
21 ->orWhere('location', 'like', '%' . $this->search . '%')
22 ->orWhere('description', 'like', '%' . $this->search . '%')
23 ->get();
24 }
25
26 public function render()
27 {
28 return view('livewire.property-list', [
29 'properties' => $this->properties,
30 ]);
31 }
README.md:0-45
 1# Liberu Real Estate
2
3![](https://img.shields.io/badge/PHP-8.3-informational?style=flat&logo=php&color=4f5b93)
4![](https://img.shields.io/badge/Laravel-11-informational?style=flat&logo=laravel&color=ef3b2d)
5![](https://img.shields.io/badge/JavaScript-ECMA2020-informational?style=flat&logo=JavaScript&color=F7DF1E)
6![](https://img.shields.io/badge/Livewire-3.0-informational?style=flat&logo=Livewire&color=fb70a9)
7![](https://img.shields.io/badge/Filament-3.2-informational?style=flat&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgeG1sbnM6dj0iaHR0cHM6Ly92ZWN0YS5pby9uYW5vIj48cGF0aCBkPSJNMCAwaDQ4djQ4SDBWMHoiIGZpbGw9IiNmNGIyNWUiLz48cGF0aCBkPSJNMjggN2wtMSA2LTMuNDM3LjgxM0wyMCAxNWwtMSAzaDZ2NWgtN2wtMyAxOEg4Yy41MTUtNS44NTMgMS40NTQtMTEuMzMgMy0xN0g4di01bDUtMSAuMjUtMy4yNUMxNCAxMSAxNCAxMSAxNS40MzggOC41NjMgMTkuNDI5IDYuMTI4IDIzLjQ0MiA2LjY4NyAyOCA3eiIgZmlsbD0iIzI4MjQxZSIvPjxwYXRoIGQ9Ik0zMCAxOGg0YzIuMjMzIDUuMzM0IDIuMjMzIDUuMzM0IDEuMTI1IDguNUwzNCAyOWMtLjE2OCAzLjIwOS0uMTY4IDMuMjA5IDAgNmwtMiAxIDEgM2gtNXYyaC0yYy44NzUtNy42MjUuODc1LTcuNjI1IDItMTFoMnYtMmgtMnYtMmwyLTF2LTQtM3oiIGZpbGw9IiMyYTIwMTIiLz48cGF0aCBkPSJNMzUuNTYzIDYuODEzQzM4IDcgMzggNyAzOSA4Yy4xODggMi40MzguMTg4IDIuNDM4IDAgNWwtMiAyYy0yLjYyNS0uMzc1LTIuNjI1LS4zNzUtNS0xLS42MjUtMi4zNzUtLjYyNS0yLjM3NS0xLTUgMi0yIDItMiA0LjU2My0yLjE4N3oiIGZpbGw9IiM0MDM5MzEiLz48cGF0aCBkPSJNMzAgMThoNGMyLjA1NSA1LjMxOSAyLjA1NSA1LjMxOSAxLjgxMyA4LjMxM0wzNSAyOGwtMyAxdi0ybC00IDF2LTJsMi0xdi00LTN6IiBmaWxsPSIjMzEyODFlIi8+PHBhdGggZD0iTTI5IDI3aDN2MmgydjJoLTJ2MmwtNC0xdi0yaDJsLTEtM3oiIGZpbGw9IiMxNTEzMTAiLz48cGF0aCBkPSJNMzAgMThoNHYzaC0ydjJsLTMgMSAxLTZ6IiBmaWxsPSIjNjA0YjMyIi8+PC9zdmc+&&color=fdae4b&link=https://filamentphp.com)
8
9
10### Other active projects
11* https://github.com/liberu-accounting/accounting-laravel
12* https://github.com/liberu-automation/automation-laravel
13* https://github.com/liberu-cms/cms-laravel
14* https://github.com/liberu-crm/crm-laravel
15* https://github.com/liberu-ecommerce/ecommerce-laravel
16* https://github.com/liberu-maintenance/maintenance-laravel
17
18### Description
19Welcome to Liberu Real Estate, our revolutionary open-source project that reshapes the real estate industry through the integration of Laravel 11, PHP 8.3, Livewire 3, and Filament 3. Liberu Real Estate is not just a software solution for property management; it's a dynamic platform designed to empower real estate professionals, property owners, and investors with innovative tools and seamless workflows.
20
21**Key Features:**
22
231. **Intuitive Property Management:** Liberu Real Estate offers an intuitive and user-friendly platform for managing real estate properties. From listings and transactions to tenant relationships, our project simplifies the complexities of property management, ensuring a streamlined and efficient experience.
24
252. **Dynamic Livewire Interactions:** Built on Laravel 11 and PHP 8.3, Liberu Real Estate integrates Livewire 3 for dynamic and real-time interactions. Update property details, manage transactions, and communicate seamlessly with clients without the need for page refreshes.
26
273. **Efficient Admin Panel:** Filament 3, our admin panel built on Laravel, provides administrators with powerful tools to manage property listings, customize settings, and oversee the entire real estate ecosystem. Liberu Real Estate ensures that your real estate operations operate seamlessly, adapting to your organization's evolving needs.
28
294. **Transaction Tracking and Reporting:** Streamline transactions and stay informed with Liberu Real Estate's comprehensive tracking and reporting features. Monitor property sales, leases, and financial transactions, ensuring accurate and up-to-date financial records.
30
315. **Customizable Listings and Search:** Tailor property listings and search functionalities to match your real estate business's unique needs. Liberu Real Estate empowers users to create customizable listings and search parameters, ensuring a personalized and efficient property search experience.
32
33Liberu Real Estate is open source, released under the permissive MIT license. We invite real estate professionals, developers, and property management teams to contribute to the evolution of real estate software. Together, let's redefine the standards of property management and create a platform that adapts to the unique needs of every real estate professional.
34
35Welcome to Liberu Real Estate – where innovation meets efficiency, and the possibilities of real estate management are limitless. Join us on this journey to transform the way we buy, sell, and manage properties in the digital age.
36
37<!--/h-->
38
39### Licensed under MIT, use for any personal or commercial project.
40
41## Demostration website
42<!--/h-->
43
44### Contributions
45
public/index.php:0-55
 1<?php
2
3use Illuminate\Contracts\Http\Kernel;
4use Illuminate\Http\Request;
5
6define('LARAVEL_START', microtime(true));
7
8/*
9|--------------------------------------------------------------------------
10| Check If The Application Is Under Maintenance
11|--------------------------------------------------------------------------
12|
13| If the application is in maintenance / demo mode via the "down" command
14| we will load this file so that any pre-rendered content can be shown
15| instead of starting the framework, which could cause an exception.
16|
17*/
18
19if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
20 require $maintenance;
21}
22
23/*
24|--------------------------------------------------------------------------
25| Register The Auto Loader
26|--------------------------------------------------------------------------
27|
28| Composer provides a convenient, automatically generated class loader for
29| this application. We just need to utilize it! We'll simply require it
30| into the script here so we don't need to manually load our classes.
31|
32*/
33
34require __DIR__.'/../vendor/autoload.php';
35
36/*
37|--------------------------------------------------------------------------
38| Run The Application
39|--------------------------------------------------------------------------
40|
41| Once we have the application, we can handle the incoming request using
42| the application's HTTP kernel. Then, we will send the response back
43| to this client's browser, allowing them to enjoy our application.
44|
45*/
46
47$app = require_once __DIR__.'/../bootstrap/app.php';
48
49$kernel = $app->make(Kernel::class);
50
51$response = $kernel->handle(
52 $request = Request::capture()
53)->send();
54
55$kernel->terminate($request, $response);
routes/channels.php:0-17
 1<?php
2
3use Illuminate\Support\Facades\Broadcast;
4
5/*
6|--------------------------------------------------------------------------
7| Broadcast Channels
8|--------------------------------------------------------------------------
9|
10| Here you may register all of the event broadcasting channels that your
11| application supports. The given channel authorization callbacks are
12| used to check if an authenticated user can listen to the channel.
13|
14*/
15
16Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
17 return (int) $user->id === (int) $id;
routes/web.php:0-25
 1<?php
2
3use Illuminate\Support\Facades\Route;
4
5/*
6|--------------------------------------------------------------------------
7| Web Routes
8|--------------------------------------------------------------------------
9|
10| Here is where you can register web routes for your application. These
11| routes are loaded by the RouteServiceProvider and all of them will
12| be assigned to the "web" middleware group. Make something great!
13|
14*/
15
16
17Route::get('/', [HomeController::class, 'index'])->name('home');
18
19
20
21
22Route::get('/properties', \App\Http\Livewire\PropertyList::class);
23});
24Route::post('/bookings', [\App\Http\Controllers\BookingController::class, 'store']);
25Route::put('/bookings/{booking}', [\App\Http\Controllers\BookingController::class, 'update']);