Skip to content

Commit

Permalink
#1
Browse files Browse the repository at this point in the history
users schema,view,controller changed for tracking approver, updating of profile by users include changing of password fulfilled,
datepicker added, php and js date format asyncronized,js alert messages changed, booking view changed, booking update after approving added
 and the bugs were created during work resolved.
  • Loading branch information
div100 committed Mar 12, 2019
1 parent a1e0dbe commit 22e0e05
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 220 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function validator(array $data)
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:6', 'confirmed','regex:/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/'],
'password' => ['required', 'string', 'min:8', 'confirmed','regex:/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/'],
'position' =>['required','string','min:4'],
'directorate'=>['required','string','min:4'],
'phone' =>['required','regex:/^07[0-9]{8}/'],
Expand Down
67 changes: 35 additions & 32 deletions app/Http/Controllers/bookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Auth;
use App\booking;
use DB;
use Response;
Expand All @@ -19,12 +19,15 @@ class bookingController extends Controller
*/
public function index()
{
$freeCars = DB::table('cars')->get();
$freeDrivers = DB::table('drivers')->get();

$approvedCount = DB::table('bookings')->where('approval',true)->count();
$rejectedCount = DB::table('bookings')->where('approval',false)->wherenotnull('approver_description')->count();
$pendingsCount = DB::table('bookings')->wherenull('approval')->wherenull('approver_description')->count();
$bookingsData = Booking::orderByDesc('pickup_time')->paginate(4);
return view('/bookings/index')->with(['bookingsData'=>$bookingsData,'approvedCount'=>$approvedCount
,'rejectedCount'=>$rejectedCount,'pendingsCount'=>$pendingsCount]);
,'rejectedCount'=>$rejectedCount,'pendingsCount'=>$pendingsCount,'freeCars'=>$freeCars,'freeDrivers'=>$freeDrivers]);

}
public function pendings(){
Expand Down Expand Up @@ -73,9 +76,9 @@ public function store(Request $request)
$created_at = now(); $updated_at = now();
$rules = array('pickup_time'=>'date|required',
'return_time'=>'after:pickup_time|date|required',
'count:numeric|min:1',
'description:string|min:10',
'destination:string|min:5');
'count'=>'numeric|min:1',
'description'=>'string|min:10',
'destination'=>'string|min:5');
$validator = Validator::make($request->all(),$rules);
if($validator->fails()){
return $validator->errors()->toArray();
Expand All @@ -90,7 +93,7 @@ public function store(Request $request)
)
"));

return "YOU HAVE SUCSSESSFULLY BOOKED VEHICAL";
return "Your booking is wait for response";
}catch(QueryException $e){
return $e->getMessage();
}
Expand Down Expand Up @@ -121,22 +124,21 @@ public function show($id)
*/
public function edit($id)
{

$bookings = Booking::find($id);
$freeCars = DB::select(DB::raw("SELECT distinct bookings.plate_no,cars.type,cars.plate_no,cars.driver_id FROM
cars LEFT JOIN bookings ON bookings.plate_no = cars.plate_no WHERE bookings.plate_no IS NULL and cars.status=true
OR approval_return_time < now()"));

$freeDrivers = DB::select(DB::raw("SELECT distinct bookings.driver_id,drivers.phone_no,drivers.driver_id,
drivers.name FROM drivers LEFT JOIN bookings ON bookings.driver_id = drivers.driver_id WHERE
bookings.driver_id IS NULL and drivers.status = TRUE OR approval_return_time < now()"));

$countPendings = DB::table('bookings')->where("approval",null)->count();
$pendings = DB::table('bookings')->where('approval',null)->get();

$pickup_to_dateTime = strtotime($bookings->pickup_time);
$return_to_dateTime = strtotime($bookings->return_time);
$p_newformat = date('Y/m/d H:i:m',$pickup_to_dateTime);
$r_newformat = date('Y/m/d H:i:m',$return_to_dateTime);


if (\Illuminate\Support\Facades\Request::ajax()) {
$bookings->pickup_time = $p_newformat;
$bookings->return_time = $r_newformat;
return $bookings;

// if (\Illuminate\Support\Facades\Request::ajax()) {

return Response::json(array('bookings'=>$bookings,'freeDrivers'=>$freeDrivers,'freeCars'=>$freeCars));}
// return Response::json(array('bookings'=>$bookings));}
}

/**
Expand All @@ -150,7 +152,7 @@ public function update(Request $request, $id)
{
//

$user_id =$request->input('user_id');
$app_user_id = Auth::user()->id;

$booking_id = $id;
$approval = $request->input('approval');
Expand All @@ -164,7 +166,7 @@ public function update(Request $request, $id)
if($approval===false||$approval==false||$approval=="false"){
try{
DB::statement(DB::raw("update bookings set approval = $approval, approver_description =
'$approver_description',approver_user_id=$user_id,updated_at=now() where booking_id = $id"));
'$approver_description',approver_user_id=$app_user_id,updated_at=now() where booking_id = $id"));
return "you have rejected";

} catch(QueryException $e){
Expand All @@ -185,18 +187,19 @@ public function update(Request $request, $id)
return $validator->errors()->toArray();
}
else{
}
try{
DB::statement(DB::raw("update bookings set plate_no=$plate_no, approval =$approval,approval_pickup_time='$approval_pickup_time'
,approval_return_time='$approval_return_time',driver_id=$driver_id,approver_description = '$approver_description',approver_user_id=$app_user_id,
updated_at=now() where
booking_id=$id"));
return "successfully approved";
}
catch(QueryException $e){
return $ex->getMessage();
}
}

try{
DB::statement(DB::raw("update bookings set plate_no=$plate_no, approval =$approval,approval_pickup_time='$approval_pickup_time'
,approval_return_time='$approval_return_time',driver_id=$driver_id,approver_description = '$approver_description',approver_user_id=$user_id,
updated_at=now() where
booking_id=$id"));
return "successfully approved";
}
catch(QueryException $e){
return $ex->getMessage();
}

}
}
// if($approval){
Expand Down
Loading

0 comments on commit 22e0e05

Please sign in to comment.