Category : lumen

I have this code, but it throw an error when i try to use it even in simplest way. <?php namespace AppJobs; use IlluminateSupportFacadesLog; class RefreshUploadedFileId extends Job { public function __construct() { // } public function handle() { Log::info(‘Hi, you reached here!’); } } Usage: use AppJobsRefreshUploadedFileId; dispatch(new RefreshUploadedFileId); Error message: Trying to access ..

Read more

I have an http client request like this? try { $request = json_encode($data); $result = $this->pendingRequest->{$method}(‘http://test.local/general/wallets/1000000’, $data); // this is my request detail $request = $result->transferStats ? Message::toString($result->transferStats->getRequest()) : $request; $result->throw(); $this->setLog($provider, $step, $request, $result->body(), $url, $result->status()); return $result; } catch (RequestException $exception) { // I need to http request detail } catch (ConnectionException $exception) ..

Read more

I have read through the documentation and a few tutorials. Sadly, I can’t seem to find any documentation on what is returned and what functions are available for use when using Eloquent. Maybe I am just missing it. However, I am using this code in my controller. public function find($userName){ $user = UserSecurity::where(‘userName’, $userName)->get(); //dd($user); ..

Read more

I’m using (latest) Lumen, which could be the culprit to my error. When I’m using updateOrCreate(): User::updateOrCreate( [‘username’ => $user->username], [ ’email’ => $user->email, ‘password’ => $user->password, ‘foreign_id’ => $user->foreign_id, ‘client_id’ => $user->client_id, ‘status’ => $user->active, ‘user_level’ => (integer) $user->user_level ] ); on one of my models, I get mysql error: "SQLSTATE[23000]: Integrity constraint violation: ..

Read more

Lumen has DB facade with select method $results = DB::select(‘select * from users where id = :id’, [‘id’ => 1]); But this dont work in WHERE IN case. DB::connection(‘db’)->selectOne("many lines of sql WHERE my_id IN (:my_id) ", ["my_id" => $new_ids]); Of course, it is possible do with query builder, DB::connection()->table(‘users’)->select()->whereIn(id, 1) But I want to ..

Read more

I want to create a forgot password feature using lumen, but I’m having a response like this: Argument 1 passed to AppHttpControllersForgotPasswordController::AppTraits{closure}() must be an instance of IlluminateMailMessage, instance of AppModelsUser given , called in D:00-LARAVEL-PROJECTS1-KANTORbaladovendorilluminateauthPasswordsPasswordBroker.php on line 66 I use trait to query the query, like this : <?php namespace AppTraits; use IlluminateHttpRequest; use ..

Read more

I want to get all of route and register to fake.php file like this: $getRouteCollection = Route::getRoutes(); //get and returns all returns route collection foreach ($getRouteCollection as $route) { Route::{‘fake/’ . $route->methods()[0]}($route->uri, [$route->getController(), $route->function()]); } i need to add prefix to all of route, and all routes work like before. Sourc..

Read more

I’m working on Lumen and my collection has duplicate values, example: collect([ [ ‘name’ => ‘John Doe’, ‘department’ => ‘Sales’, ‘phone’ => ‘99999-99999’, ‘value’ => 25.0 ], [ ‘name’ => ‘Mary Lisa’, ‘department’ => ‘Finance’, ‘phone’ => ‘88888-88888’, ‘value’ => 5.0 ], [ ‘name’ => ‘Mary Lisa’, ‘department’ => ‘Finance’, ‘phone’ => ‘88888-88888’, ‘value’ => ..

Read more

I have a abstract class like this? abstract class Create extends Command { abstract protected function sourceAccountInfo(($terminalPsp = null): ?array; public function handle() { $terminalPsp = $this->query(); if ($terminalPsp && $sourceAccountInfo = $this->sourceAccountInfo($terminalPsp) ) { $model->relations()->create($sourceAccountInfo); } } } and i have multi classes that extend create class: class PrivateCreate extends Create { protected function ..

Read more

I am facing issue when trying to download xml file Through Response Facade. So here’ what I am doing. so when i created the xml file i saved it in storage as location.xml which looks like this <?xml version="1.0"?> <locations> <location> <name>Agent</name> <designation>Agent</designation> <date>2021-08-31</date> <time>05:18:42</time> <latitude>3.0647636</latitude> <longitude>101.66423359999999</longitude> </location> <location> <name>Agent</name> <designation>Agent</designation> <date>2021-08-31</date> <time>05:18:42</time> <latitude>3.0647636</latitude> <longitude>101.66423359999999</longitude> ..

Read more

I’m creating routes for my Lumen app and I ran into the following problem. The default route has the expected return web.php $router->get(‘/’, function () use ($router) { return $router->app->version(); }); the return value: Lumen (8.2.4) (Laravel Components ^8.0) but for any URI other than this we have the following error message 500 Internal Server ..

Read more

I’m trying to secure some urls with dusterio/lumen-passport but its not working al the route are accesible, I followeb the doc this is the bootstrap/app.php <?php require_once __DIR__.’/../vendor/autoload.php’; (new LaravelLumenBootstrapLoadEnvironmentVariables( dirname(__DIR__) ))->bootstrap(); date_default_timezone_set(env(‘APP_TIMEZONE’, ‘UTC’)); /* |————————————————————————– | Create The Application |————————————————————————– | | Here we will load the environment and create the application instance | ..

Read more

I’m writing a project with Laravel.i have a loop with a lot of condition like this: foreach ($transactionsGroupBys as $transactionsGroupBy) { if ($this->checkExistSettlement($transactionsGroupBy, Carbon::today())) { $this->setErrorLog(‘This settlement has already been created’, $transactionsGroupBy); continue; } try { if ($this->doChunk()) { $transactions = $this->getTransactions($transactionsGroupBy); $maxAmountSettle = $this->configRepository->find(‘transaction_chunk:PUBLIC’)->value; $transactionChunk = app(ChunkTransaction::class)->chunk($transactions, $maxAmountSettle); foreach ($transactionChunk as $chunk) { $transactionsIds ..

Read more

I want to extract a zip to my lumen app from Laravel app, but I cant here is the code and the response. Code: public function zip(Request $request){ $this->validate($request, [ ‘folder’ => ‘file|required’ ]); $data= $request->all(); $extension = $data[‘folder’]->extension(); if ($extension == ‘zip’) { $zip = new ZipArchive; $res = $zip->open($data[‘folder’]); if ($res === TRUE) ..

Read more

i defined created at format in baseModel like this: protected function serializeDate(DateTimeInterface $date): string { return Carbon::instance($date)->toIso8601String(); } but when i use api Resource, changed created_at format this is api resource: public function toArray($request) { return [ ‘id’ => $this->id, ‘last_status’ => $this->lastStatus->status, ‘terminal’ => [ ‘provider’ => $this->terminal_provider, ‘psp’ => $this->terminal_psp, ], ‘account’ => ..

Read more

GET routes work when set up like so: $router->get(‘/user/{id}’, [‘uses’ => ‘[email protected]’]); And using this CorsMiddleware.php public function handle(Request $request, Closure $next) { $headers = [ ‘Access-Control-Allow-Origin’ => ‘*’, ‘Access-Control-Allow-Methods’ => ‘POST, GET, OPTIONS, PUT, DELETE’, ‘Access-Control-Allow-Credentials’ => ‘true’, ‘Access-Control-Max-Age’ => ‘86400’, ‘Access-Control-Allow-Headers’ => ‘Content-Type, Authorization, X-Requested-With’ ]; if ($request->isMethod(‘OPTIONS’)) { return response()->json(‘{"method":"OPTIONS"}’, 200, $headers); ..

Read more