Skip to content
100 changes: 77 additions & 23 deletions app/Filament/Resources/HouseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,97 @@ 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')
->imageEditor()
->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(),
]);
}

Expand Down
18 changes: 15 additions & 3 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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]);
}
}
1 change: 0 additions & 1 deletion app/Models/House.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions resources/views/base.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
@vite(['resources/css/app.css', 'resources/js/app.js'])
<title>@yield('title')</title>
</head>
<body>
<div class="bg-gray-100 text-gray-900">
@yield('content')
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions resources/views/pages/detail.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>salut</h1>
</body>
</html>
Loading