Skip to content

Commit

Permalink
#1
Browse files Browse the repository at this point in the history
vehical book ui generated, search for car completed, bookings view completed
  • Loading branch information
div100 committed Feb 9, 2019
1 parent 56d0ca8 commit 712b69c
Show file tree
Hide file tree
Showing 19 changed files with 645 additions and 9,238 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/public/storage
/storage/*.key
/vendor
# .env
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
Expand Down
63 changes: 59 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,68 @@
<p align="center"><h1>Vehicle Booking</h1></p>
<p align="center"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></p>

<p align="center">
<a href="#"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="#"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>

## About Vehicle Booking
## About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, yet powerful, providing tools needed for large, robust applications.

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of any modern web application framework, making it a breeze to get started learning the framework.

If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 1100 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.

## Laravel Sponsors

We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell):

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[British Software Development](https://www.britishsoftware.co)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- [UserInsights](https://userinsights.com)
- [Fragrantica](https://www.fragrantica.com)
- [SOFTonSOFA](https://softonsofa.com/)
- [User10](https://user10.com)
- [Soumettre.fr](https://soumettre.fr/)
- [CodeBrisk](https://codebrisk.com)
- [1Forge](https://1forge.com)
- [TECPRESSO](https://tecpresso.co.jp/)
- [Runtime Converter](http://runtimeconverter.com/)
- [WebL'Agence](https://weblagence.com/)
- [Invoice Ninja](https://www.invoiceninja.com)
- [iMi digital](https://www.imi-digital.de/)
- [Earthlink](https://www.earthlink.ro/)
- [Steadfast Collective](https://steadfastcollective.com/)
- [We Are The Robots Inc.](https://watr.mx/)
- [Understand.io](https://www.understand.io/)

## Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).

## Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.

## License

Expand Down
47 changes: 47 additions & 0 deletions app/Http/Controllers/book_a_car.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Http\Controllers;
use DB;
use App\booking;
use Validator;
use Illuminate\Http\Request;
use illuminate\Http\QueryException;

class book_a_car extends Controller
{
//
public function sendData(Request $request){
// return $request->input('destination') . " " .$request->input('pickup_time') . " " .$request->input('return_time') . " " .$request->input('list_of_persons') . " " .$request->input('open_drivers') . " " .$request->input('open_cars');

$destination= $request->input('destination');
$pickup_time = $request->input('pickup_time');
$return_time = $request->input('return_time');
$list_of_persons = $request->input('list_of_persons');
$open_drivers = $request->input('open_drivers');
$open_cars =$request->input('open_cars');

// $request->input('user_id') = 1;


try {

DB::table('bookings')->insert(
['start_time' => $pickup_time, 'end_time' => $return_time, 'user_id' =>1,
'list_of_persons'=>$list_of_persons,'destination' =>$destination,'driver_id'=>$open_drivers,
'car_id'=>$open_cars,'approval'=>true]
);

$id = DB::getPdo()->lastInsertId();
return "your request for car is wait for approval of admin ";
}
catch(QueryException $ex){
print($ex->getMessage());
}
}
public function driversData(Request $request){
$cars = DB::table('cars')->pluck('type');
return $cars;

}

}
145 changes: 137 additions & 8 deletions app/Http/Controllers/carController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\car;
use DB;
use Validator;
use Illuminate\Database\QueryException;


class carController extends Controller
Expand All @@ -23,6 +24,61 @@ public function index()
return view('/cars/index')->with(compact('carsData','dataCounts'));
}

public function searchCar(Request $request){

$searchOn = $request->input('searchon');
$searchInput= $request->input('searchInp');
if($searchOn == "car_id"){
$dataArray = DB::table('cars')->where("car_id",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("car_id",'LIKE',"%$searchInput%")->count();}

if($searchOn == "plate_no"){
$dataArray = DB::table('cars')->where("plate_no",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("plate_no",'LIKE',"%$searchInput%")->count();}

if($searchOn == "color"){
$dataArray = DB::table('cars')->where("color",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("color",'LIKE',"%$searchInput%")->count();}

if($searchOn == "model"){
$dataArray = DB::table('cars')->where("model",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("model",'LIKE',"%$searchInput%")->count();}

if($searchOn == "type"){
$dataArray = DB::table('cars')->where("type",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("type",'LIKE',"%$searchInput%")->count();}

if($searchOn == "status"){
if($searchInput == 'a'){$searchInput = str_replace('a', false, false);}
$dataArray = DB::table('cars')->where("status",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("status",'LIKE',"%$searchInput%")->count();}
if($searchOn == "driver_id"){
$dataArray = DB::table('cars')->where("driver_id",'LIKE',"%$searchInput%")->get();
$dataCount = DB::table('cars')->where("driver_id",'LIKE',"%$searchInput%")->count();}
if($dataCount >0 ){

foreach ($dataArray as $data) {
if($data->status === false){$data->status = 'False';}else{$data->status='True';}
echo "<tr><td><b>". $data->car_id . "</b></td>" .
"<td>" . $data->plate_no . "</td>".
"<td>" . $data->color . "</td>".
"<td>" . $data->model . "</td>" .
"<td>" . $data->type . "</td>" .
"<td>" . $data->status . "</td>" .
"<td>" . $data->driver_id . "</td>" .
"<td>" . $data->created_at . "</td>" .
"<td class='Af'>" . $data->updated_at . "</td>" .
"<td><a href='/cars/$data->car_id' id='$data->car_id' class='btn btn-primary updateBtn'>Update</a></td>
<td><a href='cars/$data->car_id' id='$data->car_id' class='deleteBtn btn btn-danger'>Delete </button></td>
</tr>";
}}

else{return "<tr><td colspan='8'><div class='card bg-light text-dark'><div class='card-body text-center' id='notFound'><h1>Data not found!</h1></div></div></td></tr>";}

}



/**
* Show the form for creating a new resource.
*
Expand Down Expand Up @@ -53,7 +109,8 @@ public function store(Request $request)
'model' => 'required',
'type' => 'required',
'status' => 'required');



$validator = Validator::make($request->all(),$rules);

if($validator->fails()){
Expand All @@ -62,9 +119,16 @@ public function store(Request $request)

}
else{
Car::create($request->all());
$id = DB::getPdo()->lastInsertId();
return 'successfully done: '. $id;

try {
Car::create($request->all());
$id = DB::getPdo()->lastInsertId();
return "successfully done " . $id;
}
catch(QueryException $ex){
print($ex->getMessage());
}

}


Expand All @@ -79,8 +143,16 @@ public function store(Request $request)
public function show($id)
{
//
$data = Car::find($id);
return $data;
$data = DB::table('cars')->where('car_id',$id)->first();
if($data->status == 1){$data->status = "True";}else{$data->status="False";}

$row = "<tr><td><b>".$data->car_id."</b></td><td>" . $data->plate_no ."</td><td>" . $data->color ."</td><td>"
.$data->model."</td><td>".$data->type."</td><td>".$data->status."</td><td>".$data->driver_id."</td><td>".$data->created_at."</td><td>".$data->updated_at.
"</td><td><a href='/cars/"
.$data->car_id ."' id='".$data->car_id."'class='btn btn-primary updateBtn' >Update</a></td><td><a a href='/cars/"
.$data->car_id ."' id='".$data->car_id. "'class='btn btn-danger deleteBtn'>Delete </button></td></td></tr>";
// return json_encode($data);
return $row;
}

/**
Expand All @@ -91,7 +163,8 @@ public function show($id)
*/
public function edit($id)
{
//
$data = Car::find($id);
return $data;
}

/**
Expand All @@ -103,9 +176,59 @@ public function edit($id)
*/
public function update(Request $request, $id)
{
//
$id;
$data = $this->edit($id);
$plate_no = $request->input('plate_no');
$color = $request->input('car_color');
$model = $request->input('car_model');
$type = $request->input('car_type');
$status = $request->input('car_status');
$driver_id = $request->input('driver_id');

if($plate_no == $data['plate_no'] && $color ==$data['color'] && $model ==
$data['model']&& $status ==$data['status']&&$type==$data['type']&&$driver_id==$data['driver_id']){
$responseErr = "There is nothing for update, please enter new things into field/fields";
return $responseErr;
}else{
$rules = array('plate_no' => 'required|string|max:6|min:3', 'car_color' => 'required|string|min:3|max:15',
'car_model' => 'required', 'car_type' => 'required','car_status' => 'required');
$validator = Validator::make($request->all(),$rules);
if($validator->fails()){
return $validator->errors()->toArray();
}
$d_id_driver = DB::table('drivers')->where('driver_id',$driver_id)->count();
$arrayOfErr = array();
if(!($data['plate_no'] == $plate_no)){$plate_count = DB::table('cars')->where('plate_no',$plate_no)->count();
if($plate_count > 0){$arrayOfErr[0] = "plate number(".$plate_no.") has already been taken";}}

if(!($data['driver_id'] == $driver_id)){
$driver_id_count = DB::table('cars')->where('driver_id',$driver_id)->count();
if($driver_id_count > 0){
$car_of_driver = DB::table('cars')->where('driver_id',$driver_id)->first();
$arrayOfErr[1] = "car with plate number of " . $car_of_driver->plate_no
. " is assigned for driver with ID ". $driver_id;}
}

if($d_id_driver<=0 && $driver_id)
{$arrayOfErr[2] = "there is no driver registered with ID of " . $driver_id . " ";}
if($arrayOfErr){
return $arrayOfErr;
}
else{
try {
$update = DB::table('cars')->where('car_id',$id)
->update(['plate_no'=>$plate_no,'color'=>$color,'model'=>$model,'type'=>$type,'status'=>$status,'driver_id'=>$driver_id]);
return "successfully updated";
}
catch(QueryException $ex){
if($ex->getMessage())
print($ex->getMessage());
}
}
}
}


/**
* Remove the specified resource from storage.
*
Expand All @@ -114,7 +237,13 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
try{
$deleteData = Car::find($id);
$deleteData->delete();
return "successfully deleted";
}
catch(QueryException $e){
print($ex->getMessage());
}
}
}
2 changes: 1 addition & 1 deletion app/car.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class car extends Model
{
protected $primaryKey = 'car_id';
protected $fillable = [
'plate_no', 'color', 'type','model','status'
'plate_no', 'color', 'type','model','status','driver_id'
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function up()
$table->string('type',25);
$table->boolean('status')->default(1);
$table->timestamps();

});
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function down()
{
Schema::table('bookings', function (Blueprint $table) {
//


});
}
}
Loading

0 comments on commit 712b69c

Please sign in to comment.