diff --git a/.env.example b/.env.example index ec44a12..ee6a59b 100644 --- a/.env.example +++ b/.env.example @@ -9,9 +9,9 @@ LOG_CHANNEL=stack DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_DATABASE=db_rentcar +DB_USERNAME=root +DB_PASSWORD= BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/app/Booking.php b/app/Booking.php new file mode 100644 index 0000000..fa5a7cd --- /dev/null +++ b/app/Booking.php @@ -0,0 +1,22 @@ +belongsTo('App\CarBrand','brand_id'); + } +} diff --git a/app/CarBrand.php b/app/CarBrand.php new file mode 100644 index 0000000..3047ec2 --- /dev/null +++ b/app/CarBrand.php @@ -0,0 +1,17 @@ +hasMany('App\Car','brand_id'); + } +} diff --git a/app/Client.php b/app/Client.php new file mode 100644 index 0000000..0b4084d --- /dev/null +++ b/app/Client.php @@ -0,0 +1,19 @@ + 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', + 'address' => 'required|string|max:255', ]); } @@ -66,6 +67,7 @@ protected function create(array $data) return User::create([ 'name' => $data['name'], 'email' => $data['email'], + 'address' => $data['address'], 'password' => Hash::make($data['password']), ]); } diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php new file mode 100644 index 0000000..16e1dc0 --- /dev/null +++ b/app/Http/Controllers/BookingController.php @@ -0,0 +1,144 @@ +all(); + return view('pages.booking.index')->with('datas', $datas); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $data['datas'] = Car::get(); + $data['datas'] = Client::get(); + return view('pages.booking.create'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $this->validate($request, [ + 'booking_code' => 'required', + 'order_date' => 'required', + 'rental_date' => 'required', + 'return_date' => 'required', + 'price' => 'required', + 'status' => 'required', + 'fine' => 'required', + 'car_id' => 'required', + 'client_id' => 'required' + ]); + + $insert = [ + 'booking_code'=> $request->booking_code, + 'order_date'=> $request->order_date, + 'rental_date'=> $request->rental_date, + 'return_date'=> $request->return_date, + 'price'=> $request->price, + 'status'=> $request->status, + 'fine'=> $request->fine, + 'car_id'=> $request->car_id, + 'client_id'=> $request->client_id + ]; + + $datas = Booking::create($insert); + return redirect()->route('booking.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $booking = new Booking; + $oldBooking = $booking->where('id', $id)->first(); + return view('pages.booking.edit')->with('booking', $oldBooking); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $this->validate($request, [ + 'booking_code' => 'required', + 'order_date' => 'required', + 'rental_date' => 'required', + 'return_date' => 'required', + 'price' => 'required', + 'status' => 'required', + 'fine' => 'required', + 'car_id' => 'required', + 'client_id' => 'required' + ]); + + $insert = [ + 'booking_code'=> $request->booking_code, + 'order_date'=> $request->order_date, + 'rental_date'=> $request->rental_date, + 'return_date'=> $request->return_date, + 'price'=> $request->price, + 'status'=> $request->status, + 'fine'=> $request->fine, + 'car_id'=> $request->car_id, + 'client_id'=> $request->client_id + ]; + + $datas = Booking::where('id', $id)->update($insert); + return redirect()->route('booking.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Controllers/CarBrandController.php b/app/Http/Controllers/CarBrandController.php new file mode 100644 index 0000000..f5c4489 --- /dev/null +++ b/app/Http/Controllers/CarBrandController.php @@ -0,0 +1,115 @@ +validate($request,[ + 'name' => 'required|min:3' + ]); + + $req = [ + 'name' => $request->name, + ]; + + $data = CarBrand::create($req); + + return redirect()->route('brand.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + $data['brand'] = CarBrand::find($id); + return view('pages.brand.edit',$data); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + $this->validate($request,[ + 'name' => 'required|min:3' + ]); + + $req = [ + 'name' => $request->name, + ]; + + $data = CarBrand::where('id',$id)->update($req); + + return redirect()->route('brand.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + CarBrand::where('id',$id)->delete(); + return response()->json($id); + } +} diff --git a/app/Http/Controllers/CarController.php b/app/Http/Controllers/CarController.php new file mode 100644 index 0000000..5c6adb7 --- /dev/null +++ b/app/Http/Controllers/CarController.php @@ -0,0 +1,116 @@ + $request->name, + 'license_plate' => $request->license_plate, + 'price' => $request->price, + 'type' => $request->type, + 'brand_id' => $request->brand_id, + 'year'=> $request->year + ]; + + $data = Car::create($req); + + return redirect()->route('car.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + $data['car'] = Car::find($id); + return view('pages.car.edit',$data); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + $req = [ + 'name' => $request->name, + 'license_plate' => $request->license_plate, + 'price' => $request->price, + 'type' => $request->type, + 'brand_id' => $request->brand_id, + 'year'=> $request->year + ]; + + $data = Car::create($req); + + return redirect()->route('car.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php new file mode 100644 index 0000000..9b4f9de --- /dev/null +++ b/app/Http/Controllers/ClientController.php @@ -0,0 +1,114 @@ + $request->nik, + 'name' => $request->name, + 'dob' => $request->dob, + 'address' => $request->address, + 'phone' => $request->phone, + 'gender' => $request->gender, + ]; + + $data = Client::create($req); + + return redirect()->route('client.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + $data['client'] = Client::find($id); + return view('pages.client.edit',$data); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + $req = [ + 'nik' => $request->nik, + 'name' => $request->name, + 'dob' => $request->dob, + 'address' => $request->address, + 'phone' => $request->phone, + 'gender' => $request->gender, + ]; + + $data = Client::where('id',$id)->update($req); + + return redirect()->route('client.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..a3af7dd --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,28 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view('home'); + } +} diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php new file mode 100644 index 0000000..4a851dc --- /dev/null +++ b/app/Http/Controllers/PaymentController.php @@ -0,0 +1,129 @@ +all(); + return view('pages.payment.index')->with('datas', $datas); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $datas = Payment::get(); + return view('pages.payment.create'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $this->validate($request, [ + 'type' => 'required', + 'amount' => 'required', + 'date' => 'required', + 'client_id' => 'required', + 'employee_id' => 'required', + 'booking_id' => 'required' + ]); + + $insert = [ + 'type'=> $request->type, + 'amount'=> $request->amount, + 'date'=> $request->date, + 'client_id'=> $request->client_id, + 'employee_id'=> $request->employee_id, + 'booking_id'=> $request->booking_id + ]; + + $datas = Payment::create($insert); + return redirect()->route('payment.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $payment = new Payment; + $oldPayment = $payment->where('id', $id)->first(); + return view('pages.payment.edit')->with('payment', $oldPayment); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $this->validate($request, [ + 'type' => 'required', + 'amount' => 'required', + 'date' => 'required', + 'client_id' => 'required', + 'employee_id' => 'required', + 'booking_id' => 'required' + ]); + + $insert = [ + 'type'=> $request->type, + 'amount'=> $request->amount, + 'date'=> $request->date, + 'client_id'=> $request->client_id, + 'employee_id'=> $request->employee_id, + 'booking_id'=> $request->booking_id + ]; + + $datas = Payment::where('id', $id)->update($insert); + return redirect()->route('payment.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index dd086fa..9a17041 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\User; class UserController extends Controller { @@ -14,7 +15,8 @@ class UserController extends Controller public function index() { // - return view('pages.user.index'); + $data['datas'] = User::get(); + return view('pages.user.index',$data); } /** @@ -38,6 +40,23 @@ public function create() public function store(Request $request) { // + $this->validate($request,[ + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6', + 'address' => 'required|string|max:255', + ]); + + $req = [ + 'name' => $request->name, + 'email' => $request->email, + 'password' => $request->password, + 'address' => $request->address, + ]; + + $data = User::create($req); + + return redirect()->route('user.index'); } /** @@ -60,6 +79,8 @@ public function show($id) public function edit($id) { // + $data['user'] = User::find($id); + return view('pages.user.edit',$data); } /** @@ -72,6 +93,24 @@ public function edit($id) public function update(Request $request, $id) { // + + $this->validate($request,[ + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6|confirmed', + 'address' => 'required|string|max:255', + ]); + + $req = [ + 'name' => $request->name, + 'email' => $request->email, + 'password' => $request->password, + 'address' => $request->address, + ]; + + $data = User::where('id',$id)->update($req); + + return redirect()->route('user.index'); } /** diff --git a/app/Payment.php b/app/Payment.php new file mode 100644 index 0000000..e90b1d0 --- /dev/null +++ b/app/Payment.php @@ -0,0 +1,18 @@ +increments('id'); + $table->string('name'); + $table->string('year'); + $table->string('license_plate'); + $table->integer('price'); + $table->string('type'); + $table->integer('brand_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cars'); + } +} diff --git a/database/migrations/2018_08_15_114334_create_car_brands_table.php b/database/migrations/2018_08_15_114334_create_car_brands_table.php new file mode 100644 index 0000000..9269eec --- /dev/null +++ b/database/migrations/2018_08_15_114334_create_car_brands_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('car_brands'); + } +} diff --git a/database/migrations/2018_08_15_114425_create_clients_table.php b/database/migrations/2018_08_15_114425_create_clients_table.php new file mode 100644 index 0000000..6cbe49c --- /dev/null +++ b/database/migrations/2018_08_15_114425_create_clients_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string ('nik'); + $table->string ('name'); + $table->date ('dob'); + $table->string('phone'); + $table->string('address'); + $table->string('gender'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('clients'); + } +} diff --git a/database/migrations/2018_08_15_114444_create_bookings_table.php b/database/migrations/2018_08_15_114444_create_bookings_table.php new file mode 100644 index 0000000..9080ac3 --- /dev/null +++ b/database/migrations/2018_08_15_114444_create_bookings_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->string('booking_code'); + $table->timestamps('order_date'); + $table->date('rental_date'); + $table->date('return_date'); + $table->integer('price'); + $table->string('status'); + $table->integer('fine'); + $table->integer('car_id'); + $table->integer('employee_id'); + $table->integer('client_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('bookings'); + } +} diff --git a/database/migrations/2018_08_15_114520_create_payments_table.php b/database/migrations/2018_08_15_114520_create_payments_table.php new file mode 100644 index 0000000..0d8893e --- /dev/null +++ b/database/migrations/2018_08_15_114520_create_payments_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('type'); + $table->integer('amount'); + $table->date('date'); + $table->integer('booking_id'); + $table->integer('client_id'); + $table->integer('employee_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payments'); + } +} diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 0000000..6ca259f --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.app') + +@section('content') +