-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/FirmanWahyudi007/MimiKost
- Loading branch information
Showing
16 changed files
with
3,435 additions
and
647 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\User; | ||
|
||
use App\Models\KamarKost; | ||
use App\Models\LokasiKost; | ||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
|
||
class KamarKostController extends Controller | ||
{ | ||
/** | ||
* Menampilkan kamar kost | ||
* | ||
* @param [int] $id | ||
* @return void | ||
*/ | ||
public function index($id){ | ||
|
||
$kamar = KamarKost::with('gambarkamars')->where('id', $id)->first(); | ||
|
||
return view('user.KamarKost', [ | ||
'kamar' => $kamar, | ||
]); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\User; | ||
|
||
use App\Models\KamarKost; | ||
use App\Models\LokasiKost; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\DB; | ||
use App\Http\Controllers\Controller; | ||
|
||
class TempatKostController extends Controller | ||
{ | ||
/** | ||
* Menampilkan list tempat kost beserta harga kamar termurah dan termahal | ||
* | ||
* @return View | ||
*/ | ||
public function index(){ | ||
|
||
$tempatKosts = DB::table('lokasi_kosts')->select('lokasi_kosts.*', | ||
DB::raw('(SELECT kamar_kosts.harga from kamar_kosts | ||
WHERE kamar_kosts.lokasi_kost_id = lokasi_kosts.id | ||
ORDER BY harga ASC LIMIT 1) as kamar_termurah'), | ||
DB::raw('(SELECT kamar_kosts.harga from kamar_kosts | ||
WHERE kamar_kosts.lokasi_kost_id = lokasi_kosts.id | ||
ORDER BY harga DESC LIMIT 1) as kamar_termahal'), | ||
)->get(); | ||
|
||
return view('user.tempatKostMobile', [ | ||
'tempatKosts' => $tempatKosts, | ||
]); | ||
} | ||
|
||
/** | ||
* Menampilkan list kamar yang ada pada tempat kosts | ||
* | ||
* @param [int] $id | ||
* @return View | ||
*/ | ||
public function show($id){ | ||
|
||
$tempat = LokasiKost::where('id', $id)->first(); | ||
$kamars = KamarKost::with('gambarkamar')->where('lokasi_kost_id', $id)->get(); | ||
$fasilitas_all = KamarKost::select('fasilitas')->where('lokasi_kost_id', $id)->get(); | ||
$fasilitas_unique = []; | ||
|
||
foreach ($fasilitas_all as $item) { | ||
$fasilitas_unique = array_unique(array_merge($fasilitas_unique, $item['fasilitas'])); | ||
} | ||
|
||
return view('user.tempatKostView', [ | ||
'tempat' => $tempat, | ||
'kamars' => $kamars, | ||
'fasilitas_unique' => $fasilitas_unique | ||
]); | ||
} | ||
|
||
/** | ||
* Sama seperti fungsi index, tetapi dengan filter | ||
* Ini digunakan untuk fungsi jquery agar tidak perlu reload | ||
* | ||
* @param Request $request | ||
* @return View | ||
*/ | ||
public function listFilter(Request $request){ | ||
|
||
$urut = $request->urut; | ||
$maxHarga = $request->maxHarga; | ||
$minHarga = $request->minHarga; | ||
|
||
$tempatKosts = DB::table('lokasi_kosts')->select('lokasi_kosts.*', | ||
DB::raw('(SELECT kamar_kosts.harga from kamar_kosts | ||
WHERE kamar_kosts.lokasi_kost_id = lokasi_kosts.id | ||
ORDER BY harga ASC LIMIT 1) as kamar_termurah'), | ||
DB::raw('(SELECT kamar_kosts.harga from kamar_kosts | ||
WHERE kamar_kosts.lokasi_kost_id = lokasi_kosts.id | ||
ORDER BY harga DESC LIMIT 1) as kamar_termahal'), | ||
) | ||
->when($urut, function ($query, $urut) { | ||
return $query->orderBy('kamar_termurah', $urut); | ||
}) | ||
->when($maxHarga, function ($query, $maxHarga) { | ||
return $query->havingRaw("kamar_termurah < $maxHarga"); | ||
}) | ||
->when($minHarga, function ($query, $minHarga) { | ||
return $query->havingRaw("kamar_termurah > $minHarga"); | ||
}) | ||
->get(); | ||
|
||
return view('user.tempatKostItem', [ | ||
'tempatKosts' => $tempatKosts, | ||
]); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.