/** * Bootstrap the application services. * * @return void */ public function boot() { /** get user related notifications */ View::composer('*', function ($view) { $user_id = Session::get('user_id'); if (Session::get('role') == 1) { //for admin $user_id = 0; // grab all the notifications where sent_to is 0 } $view->with('notifications', LicenseNotification::where('sent_to', $user_id)->orderBy('sent_on', 'desc')->get()); }); }
/** create a renewal request */ public function create_renewal_request(Request $request) { /*if(empty($request->license_type_vehicle_id)) { return redirect()->back()->with('error', trans('vehicle.request_renewal_error')); }*/ $cur_date = date("Y-m-d H:i:s"); $input_data = array('vehicle_id' => $request->vehicle_id, 'license_type_id' => $request->license_type_id, 'requested_on' => $cur_date, 'status' => 'pending'); LicenseRenewalRequest::create($input_data); $input_data = array('sent_to' => 0, 'sent_on' => $cur_date, 'message' => 'A renewal request has recieved', 'type' => 'renewal_request'); LicenseNotification::create($input_data); Session::flash('flash_message', trans('vehicle.license_renewal_request')); return redirect()->back(); }