Category : lumen

I have create this helper in Helpers folder inside Http folder: <?php namespace AppHttpHelpers; class CreateRandomId{ public static function get_id($my_table) { $id = mt_rand(1000000000, 9999999999); if($this->check_id($id,$my_table)){ get_id($my_table); } return $id; } public static function check_id($id,$my_table) { $table=DB::table($my_table)->where(‘id’,$id)->get(); if (count($table)==0){ return false; } return true; } } when I call it in controller : $new_user_id = ..

Read more

I have an object from a model, my object (retrive from AWS Athena database, just SQL query) …CoreObjectModelCardOrder, here is its structure: ^ …CoreObjectModelCardOrder {#2343 -orderId: "38496037-8709-4ac5-942f-01756a6843fc" -walletIdAttach: null -createWalletForEach: true -walletTypeId: 10 -userIdOwner: null -createUserForEach: true -number: 2 -defaultMccRestrictionGroupId: null -defaultMerchantRestrictionGroupId: null -defaultCountryRestrictionGroupId: null -defaultPermsGroup: "TRZ-CU-001" -status: "COMPLETE" -createdAt: "2021-07-27T17:39:00+02:00" -errors: [] -packageId: null ..

Read more

I have a scheduled process that need to prepare a bunch of jobs together for notification on end. Looking on Laravel documentation i fund that you can Job Batching. But apparently not in lumen, or at least is what i thought because i keep recive error during the dispach of the batch. Following the doc ..

Read more

I have two tables company and courses table The table has the following fields companies table id, full_name, email, deleted_at and courses table courses table id, company_id, course_name,deleted_at Now i would like to retrieve all courses which company is not deleted. So in my controller i have added public function index(Request $request){ $query = Courses::query(); ..

Read more

I have flutter app use login with facebook and gmail ,I want after register to return data conatin token. I have no problem with request which register in database successfully. but I get error : Unauthorized message after the request done and registered successfully : $user = User::create( [ ‘social_id’=>$request->id, ‘username’=>$request->username, ’email’=>$request->email, ‘pics’=>$request->pics, ‘role’=>’user’ ]); ..

Read more

I try to run the tests on newly installed Lumen Framework and get this error "Schema for PHPUnit 9.5 is not available". My composer.json for the project: { "name": "api/service", "description": "API Service.", "keywords": ["framework", "laravel", "lumen"], "license": "MIT", "type": "project", "require": { "php": "^7.4|^8.0", "flipbox/lumen-generator": "^8.2", "intervention/image": "^2.6", "laravel/lumen-framework": "^8.0" }, "require-dev": { "fakerphp/faker": ..

Read more

I am unable to display the items called in my show function. Anyone know why nothing is showing? The Route : $router->get(‘/contrats/{id}’, [ ‘as’ => ‘contrats.show’, ‘uses’ => ‘[email protected]’ ]); My public function show() : /** * Display the specified resource. * * @param int $id * @return IlluminateHttpResponse */ public function show(Contrat $contrat) { ..

Read more

i have number in pivot table and i dont now how i can set valur in number, The task of number filed in pivot table : Specifies the order of the video in the playlist videos title description videoUrl playlists title description playlist_videos playlist_id video_id number User::factory()->count(5) ->has(Playlist::factory()->count(3) ->has(Video::factory()->count(10) ->state(function (array $attributes, Playlist $playlist) { ..

Read more

Lumen Version: Lumen (7.2.2) Laravel Version: ^7.0 PHP Version: 7.3.27 Description: Having problem with error Target class [redirect] does not exist. This line of code: $router->get(‘/’, function () use ($router) { return redirect(‘/api-docs’); }); return error : Target class [redirect] does not exist. {"exception":"[object] (IlluminateContractsContainerBindingResolutionException(code: 0): Target class [redirect] does not exist. at /var/www/apidev/vendor/laravel/framework/src/Illuminate/Container/Container.php:811) Source: ..

Read more

I have a class for http client class in my project i need to add log and duration time. this is class: class RestClient { public static function get($provider, $step, $url, $headers = [], $data = []) { return self::request( Http::acceptJson()->withHeaders($headers), ‘get’, $url, $provider, $step, $data ); } private static function request($pendingRequest, $method, $url, $provider, ..

Read more

I registered LogConnectionFailed like this: protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], ‘IlluminateHttpClientEventsConnectionFailed’ => [ ‘AppListenersLogConnectionFailed’, ], ]; The ConnectionFailed event is fired if no response is received for a given request. my class { public function send() { $response = Http::get(‘http://example.com’); } } I need to The name of the class and ..

Read more

I need to add log after call http request in big project like this? $response = Http::get(‘http://example.com’); Log::info(`add request and header and response`); i want to define global log for all http requests. i need to define macro like this : IlluminateSupportFacadesHttp::macro(‘log’,function(){ Log::info(`add request and header and response`); }); and call http request like this: ..

Read more

I have set up the basic example of Laravel lumen with composer create-project –prefer-dist laravel/lumen demo. I am using Lumen version 8. My .env file looks like APP_NAME=Lumen APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost APP_TIMEZONE=UTC LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=mysql DB_USERNAME=root DB_PASSWORD= CACHE_DRIVER=file QUEUE_CONNECTION=sync I have created a controller TrackerController and called it in routes/web.php. // ..

Read more

I use in final class this switch case: $class = get_class($exception); switch ($class) { case SymfonyComponentHttpKernelExceptionNotFoundHttpException::class: return self::fail( ‘page not found’ ); case IlluminateDatabaseEloquentModelNotFoundException::class: return self::fail( ‘entity not found’ ); case IlluminateDatabaseQueryException::class: return self::fail( Str::contains($exception->getMessage(), ‘Duplicate’) ? ‘duplicate error’ : ‘query error’ // Check Query Exception Error ); case TypeError::class: return self::fail( ‘type error’ ); ..

Read more

I would like to read out two tables in Lumen (Laravel). The first table should be output completely and the second table only the matching entries. My code looks like this: $dbkompetenzen = DB::table(‘LD_Kompetenzen’) ->leftjoin(‘LD_SHD’, ‘LD_SHD.KompetenzID’, ‘=’, ‘LD_Kompetenzen.id’) ->where(‘LD_Kompetenzen.FachID’,’=’,$idfach) ->where(‘LD_Kompetenzen.ThemenID’,’=’,$idthemen) ->where(‘LD_SHD.SHDID’,’=’,$shdid) ->select(‘LD_Kompetenzen.id’, ‘LD_Kompetenzen.FachID’, ‘LD_Kompetenzen.ThemenID’, ‘LD_Kompetenzen.Kompetenz’, ‘LD_SHD.SHDID’, ‘LD_SHD.Ergebnis’, ‘LD_SHD.Stufe’, ‘LD_SHD.Niveau’, ‘LD_SHD.Note’, ‘LD_SHD.Datum’, ‘LD_SHD.Kuerzel’, ‘LD_SHD.background’) ->get(); Unfortunately ..

Read more

Im new to Lumen, I have managed to create and register the following ArangoDB service provider along with the service below and got it to work, but Im confused how I actually use them in another service or helper. registered the provider in bootstrap/app.php $app->register(AppProvidersArangoServiceProvider::class); ArangoServiceProvider.php <?php namespace AppProviders; use IlluminateSupportServiceProvider; class ArangoServiceProvider extends ServiceProvider ..

Read more

How would I go about using ArangoDB in Lumen? I have added arango to my composer. ("triagens/arangodb": "v3.8.0") The setup connection options here: https://www.arangodb.com/docs/stable/drivers/php-tutorial.html Where would I add this code in Lumen? in the bootstrap app.php? After successfully adding it, how would I use the connection in my controllers? I have used it before with ..

Read more

I am trying to implement scheduled task in Lumen to insert some records. This is my Command: namespace AppConsoleCommands; use AppModelsChecklist; use AppModelsInputChecklist; use CarbonCarbon; use IlluminateConsoleCommand; class DailyInput extends Command { protected $signature = ‘my:daily’; protected $description = ”; public function __construct() { parent::__construct(); } public function handle() { $insert = array(); $today = ..

Read more

I’m new to Lumen, and have a fresh install (v8.2.4) and have followed the docs, trying to write my own service, but I keep getting error "Target class [AppProdiversBatmanServiceProvider] does not exist." Like I said, its a fresh install according to the Lumen docs. in /bootstrap/app.php $app->register(AppProvidersBatmanServiceProvider::class); in /app/Providers/BatmanServiceProvider.php namespace AppProviders; use IlluminateSupportServiceProvider; class BatmanServiceProvider ..

Read more

i have query like this: $user2 = $this->user->query() ->select(‘uid’, ‘uuid’, ‘name’, ‘status’)->where(‘status’, 1) ->with([ ‘roles’ => function ($query) { $query->select(‘name’); }, ‘tokens’ => function ($query) use ($token) { $query->select(‘uid’, ‘token’, ‘type’, ‘expires’)->where(‘token’, $token); } ])->whereHas(‘tokens’, function (Builder $query) use ($token) { $query->where(‘token’, $token) ->where(‘expires’, ‘>=’, time()) ->where(‘type’, ‘access’); })->first()->toArray(); i want to convert to query ..

Read more

I have Laravel (Lumen) project that I need to access it by a URL with this format: http://localhost/website so for example my page1 would be http://localhost/website/page1. The problem is with the public folder. I don’t know how to take care of it to make it function like this. How should I configure Apache, .htaccess and ..

Read more