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']) +