/**
  * Display route detail information
  *
  * @param $rute_id
  * @return \Illuminate\Http\JsonResponse
  */
 public function busRouteDetail($rute_id)
 {
     $response = array();
     try {
         $routeModel = new Route();
         $busRouteModel = new BusRoute();
         $busOperationModel = new BusOperation();
         $infoRoute = $routeModel->where('rute_id', '=', $rute_id)->get()->toArray();
         $totalBusStop = $busRouteModel->select(DB::raw('count(*) as total_halte'))->where('rute_id', '=', $rute_id)->get()->toArray();
         $totalBusOperation = $busOperationModel->select(DB::raw('count(*) as total_bus'))->where('rute_id', '=', $rute_id)->get()->toArray();
         if (isset($infoRoute[0]) && isset($totalBusStop[0]) && $totalBusOperation[0]) {
             $container = array();
             $container['rute_id'] = $infoRoute[0]['rute_id'];
             $container['deskripsi'] = $infoRoute[0]['deskripsi'];
             $container['total_halte'] = $totalBusStop[0]['total_halte'];
             $container['total_bus'] = $totalBusOperation[0]['total_bus'];
             $response['code'] = 200;
             $response['data'] = $container;
         } else {
             $response['code'] = 400;
             $response['data']['msg'] = 'no route information can be found, make sure you attach a correct route identifier';
         }
     } catch (\Exception $e) {
         $response['code'] = 500;
         $response['data']['msg'] = "internal server error, please contact administrator";
     }
     header("Access-Control-Allow-Origin: *");
     return response()->json($response);
 }
Пример #2
0
 public function handleRequest()
 {
     // Encapsulate an HTTP request
     $request = new Request();
     // Don't show HTML errors for JSON
     if ($request->acceptJson()) {
         ini_set('html_errors', 0);
     }
     // Encapsulate the user session
     if (class_exists('App\\Session')) {
         $session = new App\Session($request);
     } else {
         $session = new Session($request);
     }
     $request->setSession($session);
     // Setup the dispatcher with App URL patterns
     $routes = self::getPatterns();
     if (class_exists('App\\Route')) {
         $routes = array_merge(App\Route::getPatterns($request), $routes);
     }
     $dispatcher = new Dispatcher($request, $routes);
     // Process the request
     $response = $dispatcher->processRequest($request);
     $response->setHeaders($session->getHeaders());
     // Render the response
     $response->respond();
 }
Пример #3
0
 /**
  * Query scope for published items.
  */
 public function scopePublished($query)
 {
     /*
      * If we're in dashboard don't apply filter
      */
     if (\Route::getCurrentRoute()->getName() != 'dash.works') {
         $query->where('published_at', '<=', Carbon::now())->where('status', $this->PUBLISHED);
     }
 }
Пример #4
0
 public function createRoute(Request $request)
 {
     $user = Auth::user();
     //Save Route
     $route = new Route();
     $route->rname = $request->input('rname');
     $waypoints = explode(";", $request->input('waypoints'));
     array_pop($waypoints);
     $route->user_id = $user->id;
     $route->save();
     //Save Waypoints
     foreach ($waypoints as $key => $waypoint) {
         $newWaypoint = new Waypoint();
         $newWaypoint->route_id = $route->id;
         $newWaypoint->index = $key;
         $newWaypoint->addr = $waypoint;
         $newWaypoint->save();
     }
     return Redirect::action('PagesController@dashboard');
 }
Пример #5
0
 public function getPhotoAttribute($value)
 {
     //dd(Route::currentRouteName());
     $currentRouteName = Route::currentRouteName();
     $pattern = '/admin./';
     $result = preg_match($pattern, $currentRouteName);
     if (!$result) {
         return url($value);
     } else {
         return $value;
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('route')->delete();
     DB::unprepared('ALTER TABLE route AUTO_INCREMENT = 1');
     Route::create(['rute_id' => '1A', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Prambanan, Bandara Adisutjipto, Stasiun Tugu, Malioboro, JEC"]);
     Route::create(['rute_id' => '1B', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Bandara Adisutjipto, JEC, km 0, UGM) dan Rute 3B (Terminal Giwangan, UGM, Ringroad Utara, Bandara Adisutjipto, Kotagede"]);
     Route::create(['rute_id' => '2A', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Jombor, Malioboro, Kotagede, Kridosono, UGM, Terminal Condongcatur"]);
     Route::create(['rute_id' => '2B', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Jombor, Terminal Condongcatur, UGM, Kridosono, Kotagede, km 0"]);
     Route::create(['rute_id' => '3A', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Giwangan, Kotagede, Bandara Adisutjipto, Ringroad Utara, UGM, Malioboro"]);
     Route::create(['rute_id' => '3B', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Giwangan, UGM, Ringroad Utara, Bandara Adisutjipto, Kotagede"]);
     Route::create(['rute_id' => '4A', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Giwangan, Tamansiswa, Puro Pakualaman, Lempuyangan, Kridosono"]);
     Route::create(['rute_id' => '4B', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now(), 'deskripsi' => "Terminal Giwangan, XT Square, SGM, Balaikota, UIN, Kridosono, Balai Yasa"]);
 }
 public function store(CreateNotifyRequest $request)
 {
     //how to fetch all input and fetch each individual
     //Route::create($request->all());
     $input = Request::all();
     //$input = Request::get('day');
     //$input['out_hamilton'] = ('outbound');
     Route::create(Request::all());
     //Route::create($input);
     return redirect('routes');
     return $input;
     //validation
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $route = Route::find($id);
     /*$invoice =  DB::table("invoices")->where("company_id","=",$id)->get();
     
             if(count($invoice)>0){
                 return response()->json("This Record cannot be deleted!<br>Bill Transactions is already existing against this company");
                 exit;
             }*/
     if ($route->delete()) {
         Session::flash("success_message", "Record Successfully deleted");
         echo "Route Successfully Deleted";
         exit;
     }
 }
Пример #9
0
 public function home()
 {
     $trips = Trip::all();
     $routes = Route::all();
     return view('home', compact('trips', 'routes'));
 }
Пример #10
0
 public function destroy($id)
 {
     $response = \App\Route::destroy($id);
     return response()->json($response);
 }
 public function run()
 {
     DB::table('routes')->delete();
     $faker = Faker\Factory::create();
     $data = \Rome2RioData::call('cebu', 'manila');
     foreach ($data->routes as $route) {
         $new_route = new App\Route();
         $new_route->name = $route->name;
         $new_route->distance = $route->distance;
         $new_route->duration = $route->duration;
         $new_route->price = \Rome2RioData::getRome2RioPrice($route);
         //ctrl + p and look for rome2riodata in facades folder
         $new_route->save();
         $i = 1;
         foreach ($route->stops as $stop) {
             $stopObj = new Stop();
             $stopObj->name = $stop->name;
             $stopObj->kind = $stop->kind;
             $stopObj->pos = $stop->pos;
             $stopObj->tips = $faker->text(20);
             $stopObj->timezone = property_exists($stop, "timeZone") ? $stop->timeZone : "";
             $stopObj->region_code = property_exists($stop, "regionCode") ? $stop->regionCode : "";
             $stopObj->save();
             unset($stopObj);
         }
         /**
          * Loop here kay each routes naay segments
          *  
          */
         foreach ($route->segments as $segment) {
             //check if the segment is flight then passes it to the
             //converting function
             //the function then returns a generic segment object
             if ($segment->kind == "flight") {
                 $segment = \Rome2RioData::convertToFlightSegment($route, $segment);
             }
             $new_segment = new App\Segment();
             $new_segment->mode = $segment->kind;
             $new_segment->route_id = $new_route->id;
             $new_segment->sequence = $i;
             $new_segment->origin_name = $segment->sName;
             $new_segment->destination_name = $segment->tName;
             $new_segment->origin_pos = $segment->sPos;
             $new_segment->destination_pos = $segment->tPos;
             $new_segment->price = \Rome2RioData::getRome2RioPrice($segment);
             //ctrl + p and look for rome2riodata in facades folder
             $new_segment->path = property_exists($segment, 'path') ? $segment->path : '';
             $new_segment->distance = $segment->distance;
             $new_segment->duration = $segment->duration;
             $new_segment->save();
             $new_segment->route()->associate($new_segment);
             // $new_segment->save() sad diay
             $fi = new FlightIterinary();
             $fi->days = $new_segment->itineraties;
             unset($new_segment);
             $i++;
         }
         //unset variables kada human loop
         unset($new_route, $i);
     }
 }
Пример #12
0
 public function getRoute()
 {
     $idOrigin = Input::get('origin');
     $idDestination = Input::get('destination');
     $res = Route::where('origin_location_id', '=', $idOrigin)->where('destination_location_id', '=', $idDestination)->first();
     return response()->json($res);
 }
Пример #13
0
 /**
  * Delete a given route and redirect with a flash message.
  *
  * @param Route $route
  */
 public function destroy(Route $route)
 {
     $route->delete();
     return redirect()->route('admin.routes.index')->with(['flash_message' => 'Linha deletada.', 'flash_message_level' => 'success']);
 }
Пример #14
0
<?php

use App\App;
use App\Route;
use App\Authentication\Authentication;
include './config.php';
include './autoload.php';
App::begin();
Authentication::auth();
Route::get();
App::end();
Пример #15
0
<?php

require_once 'engine/utils.php';
require_once 'engine/autoload.php';
Autoload::init('config/autoload.php');
use App\Config, App\Request, App\User, App\Route, App\View, App\Timer, App\Debug, App\Mysql, App\Response;
try {
    Config::load('config/settings.php');
    Config::applyHostSettings('config/hosts.php');
    Mysql::setHost(Config::get('dbConnection'));
    Timer::start();
    User::startSession();
    Request::parse();
    Route::add(['/dumper' => 'dumper', '/module' => 'module', '/login' => 'login', '/tasks' => 'page', '/profile' => 'page', '/projects' => 'page', '/workspace' => 'page', '/404' => 'error', '/' => 'page']);
    Route::go();
    Timer::showExecutionTime();
    Mysql::showResources();
    Response::out();
} catch (\Exception $e) {
    Debug::showException($e);
}
Пример #16
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     return View("buses.index", ["buses" => Bus::all(), "title" => "Buses' Listing", "routes" => Route::all()]);
 }
 /**
  * @param $token
  * @param $origin_name
  * @param $lng
  * @param $lat
  * @param $mode
  * @return \Illuminate\Http\JsonResponse
  */
 public static function addSegment($token, $origin_name, $lng, $lat, $mode)
 {
     //todo
     $segment = new Segment();
     $segment->origin_name = $origin_name;
     $segment->origin_pos = $lat . ',' . $lng;
     $segment->mode = $mode;
     $iterinary = self::getUserCurrentIterinary($token);
     $route = $iterinary->route()->first();
     //        dd($route->segments()->count());
     $segment->sequence = $route->segments()->count() + 1;
     $user = self::getByToken($token);
     //dd($route->count());
     //dd($route);
     if ($route->count() < 1) {
         $route = new Route();
         $route->name = $iterinary->origin . ' to ' . $iterinary->desination;
         try {
             $route->save();
             $iterinary->route()->associate($route);
             $iterinary->save();
         } catch (\Exception $e) {
             //dd($iterinary,$route);
             return response()->json('error saving route', 400);
         }
     }
     $route = $iterinary->route()->first();
     // activity
     $activity = new Activity();
     $activity->iterinary_id = $iterinary->id;
     $activity->day = self::getDiffInDays($token, $iterinary->id);
     $activity->start_time = Carbon::now()->toTimeString();
     // end activity
     $route->segments()->save($segment);
     $segment->activity()->save($activity);
     $iterinary = Iterinary::findOrFail($iterinary->id)->with('activities.typable')->first();
     //self::newUserActivity('transport', $segment->getAttribute('id'), $token);
     return response()->json($iterinary, 200);
 }
Пример #18
0
 /**
  * Edit a trip.
  *
  * @param Trip $trip
  * @return Response
  */
 public function edit(Trip $trip)
 {
     $routes = Route::lists('name', 'id');
     return view('trips.edit', compact('routes', 'trip'));
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function populateRoutes()
 {
     $inputs = ['origin' => rawurlencode(Input::get('origin')), 'destination' => rawurlencode(Input::get('destination')), 'pax' => Input::get('pax')];
     $airports = [];
     $user_id = Input::get('user_id');
     $contributor = User::find($user_id);
     $now = Carbon::now();
     if ($contributor == null) {
         return response()->json('user not found.', 404);
     }
     $data = Rome2Rio::call($inputs['origin'], $inputs['destination']);
     if (isset($data->airports)) {
         foreach ($data->airports as $airport) {
             $airports[$airport->code] = $airport->pos;
         }
     }
     foreach ($data->routes as $route) {
         $iterinary = new Iterinary();
         $iterinary->origin = $data->places[0]->name;
         $iterinary->destination = $data->places[1]->name;
         $iterinary->creator_id = $contributor->id;
         $iterinary->duration = $route->duration;
         $iterinary->distance = $route->distance;
         $iterinary->price = Rome2Rio::getRome2RioPrice($route);
         $new_route = new Route();
         $new_route->name = $route->name;
         $new_route->distance = $route->distance;
         $new_route->duration = $route->duration;
         $new_route->price = Rome2Rio::getRome2RioPrice($route);
         $new_route->save();
         $iterinary->route()->associate($new_route);
         $iterinary->save();
         $contributor->iterinaries()->attach($iterinary->id, ['date_start' => $now]);
         $i = 1;
         foreach ($route->segments as $segment) {
             $new_segment = new Segment();
             if ($segment->kind == "flight") {
                 $segment = Rome2Rio::convertToFlightSegment($segment, $data);
             }
             $new_segment->mode = !isset($segment->subkind) ? $segment->kind : $segment->subkind;
             $new_segment->sequence = $i;
             $new_segment->origin_name = !isset($segment->sName) ? "" : $segment->sName;
             $new_segment->destination_name = !isset($segment->tName) ? "" : $segment->tName;
             $new_segment->origin_pos = $segment->sPos;
             $new_segment->destination_pos = $segment->tPos;
             $new_segment->price = Rome2Rio::getRome2RioPrice($segment);
             $new_segment->path = $segment->kind == "flight" ? Rome2Rio::getFlightPath($airports[$segment->sCode], $airports[$segment->tCode]) : $segment->path;
             $new_segment->distance = $segment->distance;
             $new_segment->duration = $segment->duration;
             $new_route->segments()->save($new_segment);
             $activity = new Activity();
             $activity->iterinary_id = $iterinary->id;
             $activity->day = 1;
             $activity->start_time = Carbon::now()->toTimeString();
             $activity->end_time = Carbon::now()->addMinute($segment->duration)->toTimeString();
             $new_segment->activity()->save($activity);
             $i++;
         }
         unset($i);
         // unset index for segments sequence
     }
     //dd($data);
 }
 /**
  * contributor new iterinary
  * @param $request
  * @route 'plot/iterinary/new'
  * @return Response
  */
 public function newIterinaryTest(Request $request)
 {
     $token = Input::get('token');
     $withSegment = Input::get('withSegment');
     $error_bag = array();
     if ($token == null) {
         return response()->json('token is empty', 200);
     }
     $user = userSessionHandler::user($token);
     if ($user == null) {
         return response()->json('user not found.', 404);
     }
     $lng = Input::get('lng');
     $lat = Input::get('lat');
     $origin = Input::get('origin');
     $destination = Input::get('destination');
     $origin_pos = $lat . ',' . $lng;
     $pax = Input::get('pax');
     $date_start = Carbon::now();
     $input_bag = ['origin' => $origin, 'destination' => $destination, 'pax' => $pax, 'longitude' => $lng, 'latitude' => $lat, 'date_start' => $date_start];
     $i = 0;
     foreach ($input_bag as $key => $value) {
         $value = trim($value);
         if (empty($value)) {
             $error_bag[$i] = "{$key} empty";
             $i++;
         } else {
             //
         }
     }
     //filter of false or null values
     if (array_filter($error_bag)) {
         return response()->json($error_bag, 400);
     }
     $iterinary = new Iterinary();
     $iterinary->creator_id = $user->id;
     $iterinary->origin = $origin;
     $iterinary->destination = $destination;
     if ($user->iterinaries()->save($iterinary)) {
         //$user->iterinaries()->attach($iterinary->id);
         $pivot = $user->iterinaries()->wherePivot('iterinary_id', '=', $iterinary->id)->first();
         $pivot->pivot->date_start = $date_start;
         $pivot->pivot->save();
         $route = new Route();
         $route->name = $iterinary->origin . ' to ' . $iterinary->destination;
         $route->save();
         $iterinary->route()->associate($route);
         if ($withSegment == true) {
             $segment = new Segment();
             $input_bag = ['origin name' => $origin, 'origin position' => $destination, 'user id' => $user->id, 'origin position' => $origin_pos];
             $i = 0;
             foreach ($input_bag as $key => $value) {
                 $value = trim($value);
                 if (empty($value)) {
                     $error_bag[$i] = "{$key} empty";
                     $i++;
                 } else {
                     //
                 }
             }
             //filter of false or null values
             if (array_filter($error_bag)) {
                 return response()->json($error_bag, 400);
             }
             $segment->origin_pos = Input::get('origin_pos');
             $segment->sequence = Input::get('sequence');
             $segment->mode = Input::get('mode');
             $segment->origin_name = Input::get('origin_name');
             $route->segments()->save($segment);
         }
         return response()->json('success', 200);
     } else {
         return response()->json('error saving', 401);
     }
 }
Пример #21
0
 /**
  * display routes in node
  *
  */
 public function routes($id)
 {
     $node = \App\Node::findOrFail($id);
     $routes = \App\Route::where('node_id', $id)->orderBy('routeDest')->paginate(10);
     return view('nodes.routes', compact('node', 'routes'));
 }