diff --git a/app/Filament/Resources/HouseResource.php b/app/Filament/Resources/HouseResource.php index 9e08f91..e3a7446 100644 --- a/app/Filament/Resources/HouseResource.php +++ b/app/Filament/Resources/HouseResource.php @@ -27,31 +27,30 @@ public static function form(Form $form): Form ->autofocus() ->placeholder('Address ex: 1154 Fort Street Mall'), Select::make('city') - ->required() - ->options(['Lefkosa (Nicosia)', 'Gazimagusa (Famagusta)', 'Girne (Kyrenia)', 'Guzelyurt', 'Lefke', 'Yeni Iskele']) - ->autofocus() - ->placeholder('City ex: Honolulu'), + ->options(function () { + return House::all()->pluck('city', 'city'); + }), Select::make('standard') - ->required() - ->options(['Studio', '1+1', '2+1', '3+1', '3+2', '4+1', '4+2', 'Villa', 'Room']) - ->autofocus(), + ->options(function () { + return House::all()->pluck('standard', 'standard'); + }), Select::make('monthly') - ->required() - ->options(['85', '100', '150', '200', '250', '300', '350', '400','450','500','550','600','650','700','750','800','850','900','950','1000']) - ->autofocus(), + ->options(function () { + return House::all()->pluck('monthly', 'monthly'); + }), Select::make('rent') - ->options(['1', '2', '3', '4', '5','6','7','8','9','10','11','12']) - ->required(), + ->options(function () { + return House::all()->pluck('rent', 'rent'); + }), Select::make('deposit') - ->required() - ->options(['1', '2', '3']) - ->autofocus() , + ->options(function () { + return House::all()->pluck('deposit', 'deposit'); + }), Select::make('commission') - ->required() - ->options(['1', '2', '3', '4']) - ->autofocus(), + ->options(function () { + return House::all()->pluck('commission', 'commission'); + }), FileUpload::make('image') - ->required() ->imageCropAspectRatio('1:1') ->imageResizeTargetWidth('400') ->imageResizeTargetHeight('400') @@ -59,11 +58,66 @@ public static function form(Form $form): Form ->maxSize(1024 * 1024 * 2) // 2MB ->image() ->directory(config('image_upload_path')), - Select::make('house_statue') - ->default('Available') - ->options(['Available', 'Unavailable']) - ->required(), + ->options(function () { + return House::all()->pluck('house_statue', 'house_statue'); + }), +// Select::make('city') +// ->required() +// ->options('Lefkosa') +// ->options('Gazimagusa') +// ->options('Girne') +// ->options('Guzelyurt') +// ->options('Lefke') +// ->options('Yeni Iskele') +// ->autofocus() +// ->placeholder('City ex: Honolulu'), +// Select::make('standard') +// ->required() +// ->options('Studio') +// ->options('1+1') +// ->options('2+1') +// ->options('3+1') +// ->options('3+2') +// ->options('4+1') +// ->options('4+2') +// ->options('Villa') +// ->options('Room') +// ->autofocus(), +// Select::make('monthly') +// ->required() +// ->options(['85', '100', '150', '200', '250', '300', '350', '400','450','500','550','600','650','700','750','800','850','900','950','1000']) +// ->options('85') +// ->options('100') +// ->options('150') +// ->options('200') +// +// ->autofocus(), +// Select::make('rent') +// ->options(['1', '2', '3', '4', '5','6','7','8','9','10','11','12']) +// ->required(), +// Select::make('deposit') +// ->required() +// ->options(['1', '2', '3']) +// ->autofocus() , +// Select::make('commission') +// ->required() +// ->options(['1', '2', '3', '4']) +// ->autofocus(), +// FileUpload::make('image') +// ->required() +// ->imageCropAspectRatio('1:1') +// ->imageResizeTargetWidth('400') +// ->imageResizeTargetHeight('400') +// ->imageEditor() +// ->maxSize(1024 * 1024 * 2) // 2MB +// ->image() +// ->directory(config('image_upload_path')), +// +// Select::make('house_statue') +// ->default('Available') +// ->options(['Available', 'Unavailable']) +// ->required(), ]); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index a689308..15bc3eb 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -13,13 +13,13 @@ class UserController extends Controller public function index():View | Paginator | App { $houses = House::all()->sortDesc(); +// pagination $houses = House::paginate(10); return view('pages.index', ['houses' => $houses]); } - public function search(Request $request) : View + public function search() : View { -// $city = $_POST['city']; $standard = $_POST['standard']; $monthly = $_POST['monthly']; @@ -34,7 +34,19 @@ public function search(Request $request) : View ->Orwhere('monthly', 'LIKE', '%'.$monthly.'%') ->Orwhere('rent', 'LIKE', '%'.$rent.'%') ->Orwhere('commission', 'LIKE', '%'.$commission.'%') + ->distinct() ->get(); - return view('pages.search', ['houses' => $houses]); + + if ($city == 'All' && $standard == 'All' && $monthly == 'All' && $rent == 'All' && $deposit == 'All' && $commission == 'All'){ + $houses = House::all(); + } + + + return view('pages.search', ['houses' => $houses]); + } + public function detail($id):View + { + $house = House::find($id); + return view('pages.detail', ['house' => $house]); } } diff --git a/app/Models/House.php b/app/Models/House.php index b89b638..6bc0808 100644 --- a/app/Models/House.php +++ b/app/Models/House.php @@ -8,7 +8,6 @@ /** * @method static create(array $array) * @method static select(string $string) - * @method static paginate(int $int) * @method static where(string $string, string $string1, string $string2) */ class House extends Model diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php new file mode 100644 index 0000000..52706d9 --- /dev/null +++ b/resources/views/base.blade.php @@ -0,0 +1,16 @@ + + + + + + + @vite(['resources/css/app.css', 'resources/js/app.js']) + @yield('title') + + +
+ @yield('content') +
+ + diff --git a/resources/views/pages/detail.blade.php b/resources/views/pages/detail.blade.php new file mode 100644 index 0000000..ca7fd9d --- /dev/null +++ b/resources/views/pages/detail.blade.php @@ -0,0 +1,13 @@ + + + + + + + Document + + +

salut

+ + diff --git a/resources/views/pages/index.blade.php b/resources/views/pages/index.blade.php index 1696e5a..309ba26 100644 --- a/resources/views/pages/index.blade.php +++ b/resources/views/pages/index.blade.php @@ -1,87 +1,7 @@ - - - - - Title - @vite(['resources/css/app.css', 'resources/js/app.js']) - - - -
-
- - -
-
-
-
- GNPropertie - -
- - - -
-
-
+@extends('base') +@section('title', 'Home') +@section('content') + @include('layout.header') @@ -108,12 +28,12 @@ class="inline-block w-full py-3 mr-2 text-xs font-medium leading-none text-cente class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors bg-blue-50 outline-blue-300 mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="city" id="city"> - - - - - - + @php + $houses = \App\Models\House::orderBy('city', 'asc')->distinct()->get(['city']); + @endphp + @foreach($houses as $house) + + @endforeach
@@ -122,15 +42,12 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors bg- class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="standard" id="standard"> - - - - - - - - - + @php + $houses = \App\Models\House::orderBy('standard', 'asc')->distinct()->get(['standard']); + @endphp + @foreach($houses as $house) + + @endforeach
@@ -138,26 +55,12 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt- class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="monthly" id="price"> - - - - - - - - - - - - - - - - - - - - + @php + $houses = \App\Models\House::orderBy('monthly', 'asc')->distinct()->get(['monthly']); + @endphp + @foreach($houses as $house) + + @endforeach
@@ -166,18 +69,12 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt- class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="rent" id="rent"> - - - - - - - - - - - - + @php + $houses = \App\Models\House::orderBy('rent', 'asc')->distinct()->get(['rent']); + @endphp + @foreach($houses as $house) + + @endforeach
@@ -186,9 +83,12 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt- class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="deposit" id="deposit"> - - - + @php + $houses = \App\Models\House::orderBy('deposit', 'asc')->distinct()->get(['deposit']); + @endphp + @foreach($houses as $house) + + @endforeach
@@ -196,10 +96,12 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt- class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-2 py-2.5 px-4 text-gray-700 text-base font-normal border border-gray-200 rounded-lg " name="commission" id="commision"> - - - - + @php + $houses = \App\Models\House::orderBy('commission', 'asc')->distinct()->get(['commission']); + @endphp + @foreach($houses as $house) + + @endforeach
{{-- --}} @@ -215,20 +117,25 @@ class="w-full bg-blue-50 outline-blue-300 outline-offset-4 transition-colors mt-
+
+

+ {{ $houses->count() .' Apartments Found' }} +

+
@@ -236,11 +143,7 @@ class="flex flex-wrap justify-center w-full px-4 py-2 text-sm font-medium text-w
-
-

- {{ $houses->count() .' Apartments Found' }} -

-
+ @foreach( $houses as $house)
- - - - - - - - + +@endsection diff --git a/routes/web.php b/routes/web.php index e4f96de..743c9d9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,10 +14,9 @@ | */ -Route::controller(UserController::class)->group(function (){ - Route::get('/', 'index')->name('pages.index'); -// search - Route::post('/search', 'search')->name('pages.search'); - +Route::controller(UserController::class)->name('pages.')->group(function (){ + Route::get('/', 'index')->name('index'); + Route::post('/search', 'search')->name('search'); + Route::get('/detail/{id}', 'detail')->name('detail')->where(['id' => '[0-9]+','detail' => '[a-z]+' ]); });