/** * @param \Illuminate\Http\Request $request * @param Exception $e * @return mixed */ public function render($request, Exception $e) { if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { $api = new ApiController(); return $api->respondNotFound($message = 'Not Found'); } }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule->command('inspire') // ->hourly(); $schedule->call(function () { $controller = new ApiController(); $controller->sendMail(); }); }
public function testShowAllGirlsArchievedInJsonFormat() { // Test setup $expectedResponse = new JsonResponse([], 200); $girlServiceMock = $this->getMock('App\\Services\\GirlServiceInterface'); $girlServiceMock->expects($this->once())->method('getAll')->will($this->returnValue(array())); $controller = new ApiController($girlServiceMock); // Test execution $response = $controller->allGirls(); // Test assertion $this->assertEquals($expectedResponse, $response); }
/** * Assign dependencies. * * @param Auth $auth * @param JWTAuth $jwtAuth * @param AuthTokenTransformer $transformer * @param Application $app * @param Cache $cache */ public function __construct(Auth $auth, JWTAuth $jwtAuth, AuthTokenTransformer $transformer, Application $app) { $this->auth = $auth; $this->jwtAuth = $jwtAuth; $this->app = $app; parent::__construct($transformer); }
/** * DriversController constructor. * @param AuthManager $auth * @param User $users * @param JsonRespond $jsonRespond * @param UserTransformer $userTransformer */ public function __construct(AuthManager $auth, User $users, JsonRespond $jsonRespond, UserTransformer $userTransformer) { $this->user = $auth->user(); $this->userTransformer = $userTransformer; $this->users = $users; parent::__construct($jsonRespond); }
public function __construct(DriverLocationTransformer $driverLocationTransformer, AuthManager $authManager, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->user = $authManager->user(); $this->jsonRespond = $jsonRespond; $this->driverLocationTransformer = $driverLocationTransformer; }
public function __construct(ClassTransformer $classTransfomer, GenTransformer $genTransformer, AttendanceTransformer $attendanceTransformer) { parent::__construct(); $this->classTransformer = $classTransfomer; $this->genTransformer = $genTransformer; $this->attendanceTransformer = $attendanceTransformer; }
public function __construct(AuthManager $auth, OrderTransformer $orderTransformer, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->user = $auth->user(); $this->orderTransformer = $orderTransformer; $this->jsonRespond = $jsonRespond; }
/** * AdminsController constructor. * @param UserListTransformer $userListTransformer * @param User $users * @param JsonRespond $jsonRespond * @param UserTransformer $userTransformer */ public function __construct(UserListTransformer $userListTransformer, User $users, JsonRespond $jsonRespond, UserTransformer $userTransformer) { $this->userTransformer = $userTransformer; $this->users = $users; $this->userListTransformer = $userListTransformer; parent::__construct($jsonRespond); }
public function __construct(StaffTransformer $staffTransformer, TransactionTransformer $transactionTransformer, NotificationTransformer $notificationTransformer) { parent::__construct(); $this->staffTransformer = $staffTransformer; $this->transactionTransformer = $transactionTransformer; $this->transactionTransformer->setUserId($this->user->id); $this->notificationTransformer = $notificationTransformer; }
/** * Prepares for custom data transformations. */ public function __construct() { // Without this $controllerErrors will not get merged into the error list parent::__construct(); // Differently from the LeaseTransformer, ResourceTransformer this one is not controlled by Fractal for 2 reasons: // a) transformation is needed even BEFORE data is used by ApiController // b) since the collection structure is change, Fractal's transform() is not sufficient $this->transformer = new ResourceTransformer(); }
public function __construct(BaseModel $parentModel, TransformerInterface $transformer) { $this->parentModel = $parentModel; if (!$this->relationName) { throw new \InvalidArgumentException('You must specify relationName in ' . static::class); } if (!method_exists($parentModel, $this->relationName)) { throw new \InvalidArgumentException('Relation ' . $this->relationName . ', required by ' . static::class . ', does not exist in ' . get_class($parentModel)); } parent::__construct($transformer); }
/** * Show the application dashboard to the user. * * @return Response */ public static function login(Request $request) { $input = $request::all(); $username = $request::get('username'); $password = $request::get('password'); if ($username == null || $password == null) { return ApiController::wrongDataFormat(); } $user = User::where('username', '=', $username)->first(); if ($user == null) { return UserApiController::usernameNotFound(); } if (!Hash::check($password, $user['password'])) { return response()->json(['code' => 4]); } return response()->json(['code' => 0, 'user' => $user]); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { $api = new ApiController(); $message = 'Sorry, something went wrong.'; $extra = []; if ($e instanceof Tymon\JWTAuth\Exceptions\TokenExpiredException) { return $api->respondUnauthorizedError("token expired"); } else { if ($e instanceof Tymon\JWTAuth\Exceptions\TokenInvalidException) { return $api->respondBadRequestError("token invalid"); } else { if ($e instanceof Tymon\JWTAuth\Exceptions\JWTException) { return $api->respondUnauthorizedError("token absent"); } else { if ($e instanceof NotFoundHttpException) { $message = "The URI requested is invalid or the resource requested does not exist"; } } } } // If the app is in debug mode if (config('app.debug')) { // Add the exception class name, message and stack trace to response $extra['exception'] = get_class($e); // Reflection might be better here $extra['message'] = $e->getMessage(); $extra['trace'] = $e->getTrace(); } // Default response of 400 $api->setStatusCode(400); // If this exception is an instance of HttpException if ($this->isHttpException($e)) { // Grab the HTTP status code from the Exception $api->setStatusCode($e->getStatusCode()); } // Return a JSON response with the response array and status code return $api->respondWithError($message, $extra); }
/** * DriverOrdersController constructor. * @param OrderTransformer $orderTransformer * @param JsonRespond $jsonRespond */ public function __construct(OrderTransformer $orderTransformer, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->orderTransformer = $orderTransformer; $this->jsonRespond = $jsonRespond; }
public function __construct() { parent::__construct(); $this->beforeFilter('auth', array('on' => array('post', 'put', 'delete'))); }
public function loginSso() { \Cas::authenticate(); $api = new ApiController(); $user = $api->_getUserAttributes(\Cas::getCurrentUser()); $_user = User::where('username', $user->username)->first(); if (!$_user) { $_user = new User(); $_user->email = $user->email; $_user->nip = $user->nip; $_user->username = $user->username; $_user->save(); } \Auth::login($_user); return redirect('/'); }
/** * AdminsController constructor. * @param Order $orders * @param JsonRespond $jsonRespond * @param OrderTransformer $userTransformer */ public function __construct(Order $orders, JsonRespond $jsonRespond, OrderTransformer $userTransformer) { $this->orderTransformer = $userTransformer; $this->orders = $orders; parent::__construct($jsonRespond); }
function syncInbox() { $this->msg_cnt = imap_num_msg($this->conn); $unseen_messages = imap_search($this->conn, 'UNSEEN'); if ($this->msg_cnt === 0) { } echo "no unseen mails\n"; $in = array(); for ($i = 1; $i <= $this->msg_cnt; $i++) { if ($unseen_messages && in_array($i, $unseen_messages)) { $body = imap_body($this->conn, $i, FT_PEEK); $header = imap_headerinfo($this->conn, $i); $structure = imap_fetchstructure($this->conn, $i); echo $structure->encoding; if ($structure->encoding == 4) { $body = imap_qprint($body); } echo 'faschismus'; $in[] = array('index' => $i, 'header' => $header, 'body' => $body, 'structure' => imap_fetchstructure($this->conn, $i)); //check if msg is from iridium msg service if (true) { echo 'got unseen mail from msg.iridium.com:'; echo $body; //create case if (strpos($body, 'safepassage -create') !== FALSE) { $body = trim($body); //remove syntax from beginn $json_string = str_replace('safepassage -create ', '', $body); //the iridium go replaces the "{" and "}" at the end and beginning of the json string //with "(" and ")" so it has to be rereplaced again $json_string = '{' . substr($json_string, 1); $json_string = substr($json_string, 0, -2) . '}'; $json_string = str_replace('":("', '":{"', $json_string); $json_string = str_replace(')}', '}}', $json_string); echo "\n"; echo $json_string; echo "f**k\n"; $case_array = json_decode($json_string, true); var_dump($case_array); //$case_array['location_data'] = json_encode($case_array['location_data']); /*var_dump($case_array);*/ $case_id = \App\Http\Controllers\ApiController::createCase($case_array); echo $case_id; self::sendMail($header->fromaddress, 'Re: ' . $header->subject, "Your case has been submitted. Case-ID: " . $case_id); imap_setflag_full($this->conn, $i, "\\Seen", ST_UID); } /*if(\App\Http\Controllers\Admin\VehicleController::addLocationFromIridiumMail($header, $body)){ echo 'adding location from'.$header->fromaddress; imap_setflag_full($this->conn, $i, "\\Seen", ST_UID); $body = imap_body($this->conn, $i); }else{ echo 'not now'; /*$status = imap_clearflag_full($this->conn, $i, "\\Seen \\Flagged"); imap_close($this->conn, CL_EXPUNGE); }*/ } } } //var_dump($in); $this->inbox = $in; }
/** * * Mostrar la ficha de información de transportista * * @param Request $request Objeto de Laravel que contiene la información * de la request. * @param int $id Identificador del transportista a mostrar. * @param string $entity Nombre de la entidad sobre la cual se quiere * consultar un elemento * * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory */ public function view(Request $request, $id, $entity = self::ENTITY) { return parent::view($request, $id, $entity); }
public function __construct(BaseModel $model, TransformerInterface $transformer) { $this->model = $model; parent::__construct($transformer); }
/** * Assign dependencies. * * @param Timezones $timezones * @param EloquentModelTransformer $transformer */ public function __construct(Timezones $timezones, EloquentModelTransformer $transformer) { $this->timezones = $timezones; parent::__construct($transformer); }
/** * DispatcherDriversController constructor. * @param UserTransformer $userTransformer * @param JsonRespond $jsonRespond */ public function __construct(UserTransformer $userTransformer, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->jsonRespond = $jsonRespond; $this->userTransformer = $userTransformer; }
public function __construct(CourseTransformer $courseTransformer) { parent::__construct(); $this->courseTransformer = $courseTransformer; }
public function __construct(NotificationTransformer $notificationTransformer) { parent::__construct(); $this->notificationTransformer = $notificationTransformer; }
public static function createCase($req) { $all = $req; if (!is_array($all['location_data'])) { $location_information = json_decode($all['location_data'], true); } else { $location_information = json_decode(json_encode($all['location_data']), FALSE); } //array to object $location_information = json_decode(json_encode($location_information), FALSE); $location_information->heading = 0; if (isset($location_information->longitude)) { $all['operation_area'] = \App\Http\Controllers\ApiController::getLocationArea($location_information->longitude, $location_information->latitude); } if (!isset($all['boat_status'])) { $all['boat_status'] = 'distress'; } if (!isset($all['boat_condition'])) { $all['boat_condition'] = 'unknown'; } //no operation area; if (!$all['operation_area']) { $result = []; $result['error'] = 'no_operation_area'; return json_encode($result); } $emergencyCase = new emergencyCase($all); $emergencyCase->save(); $emergencyCasePositions = [new emergencyCaseLocation(['lon' => (double) $location_information->longitude, 'lat' => (double) $location_information->latitude, 'accuracy' => $location_information->accuracy, 'heading' => $location_information->heading])]; $emergencyCase->emergency_case_locations()->saveMany($emergencyCasePositions); $result = []; $result['error'] = null; $result['data']['emergency_case_id'] = $emergencyCase->id; $result['data']['operation_area'] = $emergencyCase->operation_area; return json_encode($result); }
/** * Execute the console command. * * @return string */ public function handle() { $this->comment(PHP_EOL . ApiController::Currency() . PHP_EOL); }
public function __construct(StudentTransformer $studentTransformer) { parent::__construct(); $this->studentTransformer = $studentTransformer; }
function __construct(PostTransformer $postTransformer) { parent::__construct(); $this->postTransformer = $postTransformer; }
/** * Assign dependencies. * * @param Countries $countries * @param EloquentModelTransformer $transformer */ public function __construct(Countries $countries, EloquentModelTransformer $transformer) { $this->countries = $countries; parent::__construct($transformer); }