コード例 #1
1
 public function onUserLogin($user, $remember)
 {
     $request = Request::capture();
     $user->last_login = Carbon::now();
     $user->ip_address = $request->ip();
     $user->save();
 }
コード例 #2
1
 public function run()
 {
     $request = Request::capture();
     $config = $this->app->get("config");
     $action = $request->input($config->get('app.request_action'), '/');
     $responseContent = $this->runActionController($action);
     if (!$responseContent) {
         return;
     }
     $response = new Response($responseContent);
     $response->send();
     die;
 }
コード例 #3
0
 public function update($QuestionID)
 {
     if (!AuthController::checkPermission()) {
         return redirect('/');
     }
     $data = Request::capture();
     $count = $data['numAnswer'];
     // delete all old spaces with corresponding answers
     $oldSpaces = Spaces::where('QuestionID', '=', $QuestionID)->get()->toArray();
     foreach ($oldSpaces as $value) {
         SpacesController::destroy($value['id']);
     }
     for ($i = 0; $i < $count; $i++) {
         $rawAnswer = trim(AnswersController::c2s_convert($data['answer' . ($i + 1)]));
         preg_match_all('/([^;]+);/', $rawAnswer, $matches, PREG_PATTERN_ORDER);
         $arrayOfAnswer = $matches[1];
         $SpaceID = DB::table('spaces')->insertGetId(['QuestionID' => $QuestionID, 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()]);
         $true = true;
         foreach ($arrayOfAnswer as $value) {
             $a = new Answers();
             $a->Logical = $true;
             $a->SpaceID = $SpaceID;
             $a->Detail = trim($value);
             $a->save();
             $true = false;
         }
     }
     return redirect(route('user.viewquestion', $QuestionID));
 }
コード例 #4
0
ファイル: Grid.php プロジェクト: rafwell/laravel-grid
 function __construct($query, $id)
 {
     $this->query = $query;
     $this->id = $id;
     $this->Request = Request::capture();
     return $this;
 }
コード例 #5
0
 public function saveAction()
 {
     $request = Request::capture();
     echo '<pre>';
     var_dump($request);
     die;
 }
コード例 #6
0
ファイル: FilterTrait.php プロジェクト: paybreak/basket
 /**
  * Get Table Filter
  *
  * @author WN
  * @return Collection
  */
 protected function getFilters()
 {
     if (!$this->filters) {
         $this->filters = Collection::make(Request::capture()->except(['limit', 'page', 'download']));
     }
     return $this->filters;
 }
コード例 #7
0
ファイル: HttpServer.php プロジェクト: pauldo/lswoole
 public function setGlobal(swoole_http_request $request)
 {
     $global_arr = ['get' => '_GET', 'post' => '_POST', 'files' => '_FILES', 'cookie' => '_COOKIE', 'server' => '_SERVER'];
     foreach ($global_arr as $skey => $globalname) {
         if (!empty($request->{$skey})) {
             ${$globalname} = $request->{$skey};
         } else {
             ${$globalname} = [];
         }
     }
     if (!empty($_SERVER)) {
         foreach ($_SERVER as $key => $value) {
             $_SERVER[strtoupper($key)] = $value;
         }
     }
     $_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
     $_SERVER['REQUEST_METHOD'] = $request->server['request_method'];
     $_SERVER['REQUEST_URI'] = $request->server['request_uri'];
     $_SERVER['REMOTE_ADDR'] = $request->server['remote_addr'];
     foreach ($request->header as $key => $value) {
         $_key = 'HTTP_' . strtoupper(str_replace('-', '_', $key));
         $_SERVER[$_key] = $value;
     }
     \Illuminate\Http\Request::capture();
 }
コード例 #8
0
ファイル: LimitTrait.php プロジェクト: paybreak/basket
 /**
  * Get Page Limit
  *
  * @author MS
  */
 protected function getPageLimit()
 {
     if (Request::capture()->get('limit') && is_numeric(Request::capture()->get('limit'))) {
         return Request::capture()->get('limit');
     }
     return static::PAGE_LIMIT ? static::PAGE_LIMIT : 15;
 }
コード例 #9
0
 public function saveQuestion($PostID)
 {
     if (!AuthController::checkPermission()) {
         return redirect('/');
     }
     $data = Request::capture();
     $question = new Questions();
     $question->PostID = $PostID;
     $question->ThumbnailID = $data['ThumbnailID'];
     $question->Question = $data['Question'];
     $question->Description = $data['Description'];
     switch ($data['ThumbnailID']) {
         case '1':
             // Photo
             $question->save();
             $question = Questions::orderBy('id', 'desc')->first();
             //Photo
             $file = Request::capture()->file('Photo');
             if ($file != null) {
                 $question->Photo = 'Question_' . $PostID . '_' . $question->id . "_-Evangels-English-www.evangelsenglish.com_" . "." . $file->getClientOriginalExtension();
                 $file->move(base_path() . '/public/images/imageQuestion/', $question->Photo);
             }
             $question->update();
             break;
         case '2':
             // Video
             $linkVideo = $data['Video'];
             $question->Video = PostsController::getYoutubeVideoID($linkVideo);
             $question->save();
             break;
     }
     echo $question->id;
     return;
 }
コード例 #10
0
ファイル: general.php プロジェクト: diego1q2w/validador
 public static function setActive($path, $active = 'active')
 {
     //funcion para agregar la clase active en el menu del sistema
     if (Str::contains(Request::capture()->path(), 'auth')) {
         return '';
     }
     return Str::contains(Request::capture()->path(), $path) ? $active : '';
 }
コード例 #11
0
 /**
  * Transform a Laravel exception into an API exception.
  *
  * @param  Exception $exception
  * @return void
  */
 protected function transformException(Exception $exception)
 {
     if (Request::capture()->wantsJson()) {
         $this->transformAuthException($exception);
         $this->transformEloquentException($exception);
         $this->transformValidationException($exception);
     }
 }
コード例 #12
0
 public function run()
 {
     $router = new Router(new Dispatcher($this->container), $this->container);
     $router->get('/', HomeController::class . '@index');
     $router->get('/responsabilidad/{id}', HomeController::class . '@show');
     $response = $router->dispatch(Request::capture());
     $response->send();
 }
コード例 #13
0
ファイル: Application.php プロジェクト: juandgomez/php
 public function run()
 {
     $router = new \Illuminate\Routing\Router(new \Illuminate\Events\Dispatcher($this->container), $this->container);
     $router->get('/', \platzi\Http\Controllers\HomeController::class . '@index');
     $router->get('/post/{id}', \platzi\Http\Controllers\HomeController::class . '@show');
     //$request = Request::capture();
     $response = $router->dispatch(\Illuminate\Http\Request::capture());
     $response->send();
 }
コード例 #14
0
 private function __construct($name)
 {
     $this->request = Request::capture();
     $this->db = app(DatabaseManager::class);
     if (!$this->request->has('_DataTableQuery')) {
         throw new \Exception('Invalid input data for DataTableQuery: ' . print_r($this->request->all(), true));
     }
     $this->filters = json_decode($this->request->_DataTableQuery[$name])->{$name};
 }
コード例 #15
0
ファイル: Tree.php プロジェクト: z-song/laravel-admin
 /**
  * Render a tree.
  *
  * @return \Illuminate\Http\JsonResponse|string
  */
 public function render()
 {
     if (Request::capture()->has('_tree')) {
         return response()->json(['status' => $this->saveTree(Request::capture()->get('_tree'))]);
     }
     $this->buildupScript();
     AdminManager::script($this->script);
     view()->share(['path' => $this->path]);
     return view('admin::tree', $this->variables())->render();
 }
コード例 #16
0
 /**
  * @test
  */
 public function sets_currency_and_checks_if_it_matches()
 {
     $config = new Config($this->config);
     $provider = m::mock('SSD\\Currency\\Providers\\CookieProvider', [$config, Request::capture()]);
     $provider->shouldReceive('set')->with('usd');
     $provider->shouldReceive('is')->andReturn(true);
     $currency = new Currency($provider);
     $currency->set('usd');
     $this->assertTrue($currency->is('usd'));
 }
コード例 #17
0
ファイル: Debugbar.php プロジェクト: recca0120/laravel-tracy
 /**
  * __construct.
  *
  * @method __construct
  *
  * @param  array                                        $config
  * @param  \Illuminate\Http\Request                     $request
  * @param  \Illuminate\Contracts\Foundation\Application $app
  */
 public function __construct($config, Request $request = null, Application $app = null)
 {
     $this->request = is_null($request) === true ? Request::capture() : $request;
     $this->ajax = $this->request->ajax();
     $this->app = $app;
     $this->accepts = Arr::get($config, 'accepts', []);
     $this->showBar = Arr::get($config, 'showBar', false);
     $this->initializeTracyDebuger($config);
     $this->loadPanels($config);
 }
コード例 #18
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     User::created(function ($user) {
         $control = new PasswordController();
         $request = Request::capture();
         view()->composer('emails.password', function ($view) {
             $view->with(['new_user' => true]);
         });
         $result = $control->postEmail($request);
     });
 }
コード例 #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreateJobRequest $request)
 {
     $input = Request::capture()->all();
     $input['Employer_id'] = Auth::id();
     $input['updated_at'] = Carbon::now();
     Job::create($input);
     \Session::flash('msg', 'You Have Successfully Added Job' . $input['title']);
     // return $input;
     //return $input['Employer_id'];
     return redirect('job/openings');
 }
コード例 #20
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $this->setDefaultPermalinkStructure($app);
     $app['actions']->listen('init', function () use($app) {
         $this->extractWordPressClasses($app);
         $this->bootstrapRoutes($app['router']);
     });
     $app['actions']->listen('admin_init', function () use($app) {
         do_action('template_redirect');
         $app['wp_admin_response'] = $app[Kernel::class]->handle($request = Request::capture());
     });
 }
コード例 #21
0
 public function test_datatables_make_with_data_and_uses_mdata()
 {
     $builder = $this->setupBuilder();
     // set Input variables
     $this->setupInputVariables();
     $datatables = new Datatables(Request::capture());
     $response = $datatables->usingCollection($builder)->make(true);
     $actual = $response->getContent();
     $expected = '{"draw":1,"recordsTotal":2,"recordsFiltered":2,"data":[{"id":1,"name":"foo"},{"id":2,"name":"bar"}]}';
     $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
     $this->assertEquals($expected, $actual);
 }
コード例 #22
0
 public function createDataset(array $searchableFields)
 {
     if (!$this->dataTableQueryName) {
         throw new GirolandoComponentException('Chamada ao createDataset sem informar antes o dataTAbleQueryName pelo método usingDataTableQuery()');
     }
     $queryBuilder = $this->service->getQuery();
     $dataTableQuery = DataTableQuery::getInstance($this->dataTableQueryName);
     $filters = (array) $dataTableQuery->getFilters();
     foreach ($searchableFields as $key => $field) {
         $searchableFields[$key] = strtolower($field);
     }
     if ($filters) {
         $nfilters = [];
         $orFilters = [];
         foreach ($filters as $filter => $value) {
             if (!in_array(strtolower($filter), $searchableFields)) {
                 continue;
             }
             //O filtro é pra OR??
             if (strpos($value, '|') !== false) {
                 $orFilters[$filter] = explode('|', $value);
                 continue;
             }
             $nfilters[$filter] = $value;
         }
         if ($nfilters) {
             $queryBuilder = $this->service->findBy($nfilters);
         }
         if ($orFilters) {
             foreach ($orFilters as $filter => $values) {
                 $queryBuilder->whereIn($filter, $values);
             }
         }
         if ($queryBuilder instanceof \Illuminate\Database\Eloquent\Builder) {
             $queryBuilder = $queryBuilder->getQuery();
         }
     }
     $queryBuilder->select(['*']);
     $dataset = $dataTableQuery->apply($queryBuilder);
     $request = Request::capture();
     if ($request->has('customFilters')) {
         $customFilters = $request->get('customFilters');
         $dataset->where(function ($query) use($customFilters) {
             foreach ($customFilters as $filter => $value) {
                 $query->orWhere($filter, 'like', $value);
             }
         });
     }
     return $dataset;
 }
コード例 #23
0
 public function checkCaptcha()
 {
     $request = Request::capture();
     $response = $request->get('g-recaptcha-response');
     $remoteIP = $request->ip();
     $secret = env('RECAPTCHA_SECRET_KEY');
     $reCaptcha = new ReCaptcha($secret);
     $result = $reCaptcha->verify($response, $remoteIP);
     if ($result->isSuccess()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #24
0
ファイル: OAuthGetUser.php プロジェクト: edcoreweb/dominox
 /**
  * Handle the event.
  *
  * @param  \App\WS\Message $message
  * @param  \App\WS\Connection $conn
  * @return void
  */
 public function handle($message, $conn)
 {
     $request = Request::capture();
     $request->query->add(['code' => $message->data('code')]);
     $provider = $message->data('provider');
     $user = Socialite::driver($provider)->stateless()->setRequest($request)->user();
     if ($u = User::findByProvider($provider, $user->getId())) {
         return $this->send($message->from(), $message->event(), $u->setHidden([]));
     }
     if (User::where('email', $user->getEmail())->exists()) {
         return $this->send($message->from(), $message->event(), 'The email has already been taken.', 422);
     }
     $user = User::create(['name' => $user->getName(), 'email' => $user->getEmail(), 'avatar' => $user->getAvatar(), 'provider' => $provider, 'provider_id' => $user->getId(), 'api_token' => str_random(32)]);
     return $this->send($message->from(), $message->event(), $user->setHidden([]), 201);
 }
コード例 #25
0
 protected function runSeed($class)
 {
     // Boot Laravel Framework
     $app = (require_once \Sledgehammer\PATH . 'bootstrap/app.php');
     $request = \Illuminate\Http\Request::capture();
     $app['request'] = $request;
     $app->bootstrapWith(['Illuminate\\Foundation\\Bootstrap\\DetectEnvironment', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\ConfigureLogging', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders']);
     // Run the seeder
     $command = new DevutilsCommand();
     // @todo implement formatter
     $command->setOutput(new BufferedOutput());
     $seeder = new Seeder();
     $seeder->setCommand($command);
     $seeder->setContainer($app);
     $seeder->call($class);
     // Return the result
     return new Alert(nl2br(Html::escape($command->getOutput()->fetch())), ['class' => 'alert alert-info']);
 }
コード例 #26
0
 public function dic()
 {
     $data = Request::capture();
     // https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
     $response = \Unirest\Request::get("https://glosbe.com/gapi/translate", null, array('from' => 'eng', 'dest' => 'eng', 'format' => 'json', 'phrase' => $data['word'], 'pretty' => 'false', 'tm' => 'true'));
     $ms = json_decode($response->raw_body);
     // dd($ms);
     // Get Examples in $ms->examples. English in $ms->examples->first, Other Language in $ms->examples->second
     $examples = array();
     // Get English Meaning in $ms->meanings, other language in $ms->phrase
     $meanings = array();
     if (count($ms->examples) > 0) {
         $i = 0;
         foreach ($ms->examples as $key => $value) {
             if (isset($value->first)) {
                 $examples += array($key => $value->first);
             }
             $i++;
             if ($i >= 5) {
                 break;
             }
         }
     }
     // dd($examples);
     if (isset($ms->tuc)) {
         if (count($ms->tuc) > 0) {
             $ms = json_decode($response->raw_body)->tuc[0]->meanings;
         }
         // dd($ms[0]->text);
         // dd($ms);
         $i = 0;
         foreach ($ms as $key => $value) {
             $meanings += array($key => $value->text);
             $i++;
             if ($i >= 5) {
                 break;
             }
         }
     }
     // dd($meanings);
     echo json_encode(['meanings' => $meanings, 'examples' => $examples]);
     // dd(['examples' => $examples, 'meanings' => $meanings]);
 }
コード例 #27
0
ファイル: Laravel.php プロジェクト: recca0120/laravel-bridge
 /**
  * __construct.
  *
  * @method __construct
  */
 public function __construct()
 {
     $this->app = new Container();
     $this->request = Request::capture();
     $this->dispatcher = new Dispatcher();
     $this->config = new Fluent();
     $this->files = new Filesystem();
     $this->app['request'] = $this->request;
     $this->app['events'] = $this->dispatcher;
     $this->app['config'] = $this->config;
     $this->app['files'] = $this->files;
     Facade::setFacadeApplication($this->app);
     foreach ($this->aliases as $alias => $class) {
         if (class_exists($alias) === true) {
             continue;
         }
         class_alias($class, $alias);
     }
 }
コード例 #28
0
 public function update($QuestionID)
 {
     $question = Questions::find($QuestionID);
     $old_subquestions = Subquestions::where('QuestionID', '=', $QuestionID)->get()->toArray();
     foreach ($old_subquestions as $value) {
         SubquestionsController::destroy($value['id']);
     }
     $data = Request::capture()->all();
     $count = $data['numAnswer'];
     for ($i = 0; $i < $count; $i++) {
         $subQ = $data['answer' . ($i + 1)];
         $SubQuestionID = DB::table('subquestions')->insertGetId(['QuestionID' => $QuestionID, 'Question' => $subQ, 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()]);
         $answer = new Answers();
         $answer->SubQuestionID = $SubQuestionID;
         $answer->Detail = $data['ta_answer' . ($i + 1)];
         $answer->Logical = 1;
         $answer->save();
     }
     return redirect(route('user.viewquestion', $QuestionID));
 }
コード例 #29
0
 public function uploadFile()
 {
     $request = Request::capture();
     $file = $request->file('file');
     $fileName = $request->input('filename');
     $width = $request->input('width');
     $height = $request->input('height');
     if ($file->isValid()) {
         $tmpName = $file->getFilename();
         $realPath = $file->getRealPath();
         $extension = $file->getClientOriginalExtension();
         $fileType = $file->getMimeType();
     }
     $picURL = 'urla-------';
     /*
     $client = S3Client::factory(array(
         'region'      => 'us-west-2',
         'version'     => 'latest',
         'credentials' => [
             'key'    => 'AKIAICY5UKOXG57U6HGQ',
             'secret' => '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',
         ],
     ));
     
     $s3key = 'tempKey';
     $result = $client->putObject(array(
         'ACL'        => 'public-read',
         'Bucket'     => 'questionbucket',
         'Key'        => $s3key,
         'SourceFile' => $realPath
     ));
     
     $picURL = $result['ObjectURL'];
     */
     try {
         $picture = Picture::create(['original_pic' => $picURL, 'bmiddle_pic' => $picURL, 'thumbnail_pic' => $picURL, 'pictureName' => $fileName, 'width' => $width, 'height' => $height]);
         return Utility::response_format(Utility::RESPONSE_CODE_SUCCESS, $picture->getAttributes(), '上传成功');
     } catch (Exception $e) {
         return Utility::response_format(Utility::RESPONSE_CODE_DB_ERROR, '', $e->getMessage());
     }
 }
コード例 #30
0
 public function register()
 {
     $request = Request::capture();
     $username = $request->input('username');
     $password = $request->input('password');
     $nickname = $request->input('nickname');
     $age = $request->input('age');
     $information = $request->input('information');
     $location = $request->input('location');
     $headPic = $request->input('headPicture');
     $homePic = $request->input('homePicture');
     if ($username == null || $password == null) {
         // 账号 密码 不能为空
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '账号密码不能为空');
     } else {
         if (UserAccount::where('username', $username)->first() != null) {
             return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '账号已存在');
         } else {
             if (Utility::isValidateUsername($username) == false) {
                 // 用户名无效
             } else {
                 if (Utility::isValidatePassword($password) == false) {
                     // 密码无效
                 }
             }
         }
     }
     $token = Utility::genToken();
     DB::beginTransaction();
     try {
         $user = UserAccount::create(['username' => $username, 'password' => $password, 'token' => $token]);
         $userInfo = UserInfo::create(['user_name' => $nickname, 'user_age' => $age, 'user_information' => $information, 'user_location' => $location, 'user_id' => $user->id, 'head_pic' => $headPic, 'home_pic' => $homePic]);
         DB::commit();
         $userInfo['token'] = $user->token;
         $userInfo['tags'] = $user->userTags;
         return $userInfo;
     } catch (Exception $e) {
         DB::rollBack();
         return Utility::response_format(Utility::RESPONSE_CODE_DB_ERROR, '', $e->getMessage());
     }
 }