Marius Pantea

Marius Pantea

MaravelQL | Equivalent constant torque

About

Creator of MaravelQL Creator of maravel-rest-wizard / laravel-crud-wizard-free lib suites Definer of Equivalent constant engine torque

Badges

Tastemaker
Tastemaker
Gone streaking 10
Gone streaking 10
Gone streaking
Gone streaking
Gone streaking 25
Gone streaking 25
View all badges

Maker History

Forums

The Zero-Cost Boot Hack Every Maravel Developer Needs to Know

I had to configure the mail on Maravel.

The Lumen usual path would had been:

// bootstrap/app.php
$app->configure('mail'); $app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class); $app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class); $app->register(Illuminate\Mail\MailServiceProvider::class);

But this will execute those on each request even if the request will not send any email.

Maravel Micro-Framework 10.32.35 With Built-in CruFd Freemium MaravelQL is Out

Version 10.52.35 of Maravel Micro-Framework is out with built-in cruFd (Create, Read, Update, Filter and Delete).

Forget about implementing filters for each of your resource. MaravelQL handles that for you.

It requires the latest Maravel-Framework 10.65 and the laravel-crud-wizard-free lib suite composed of:

  • laravel-crud-wizard-free

  • laravel-crud-wizard-decorator-free

  • laravel-crud-wizard-generator

Segregated Relations Maravel-Framework 10.65

Now you can define your relations like this, in one place in your model:

// model protected function segregatedRelationsDefinitionMap(): array { return [ 'relName' => fn(): HasOne => $this->hasOne(Model::class, 'model_id', 'id'), // Reuse the segregatedrelation inside another segregated relation: 'relNameScoped' => fn(): HasOne => $this->relName()->where('col', '=', 'text'), 'relNameScoped2' => fn(): HasOne => $this->callSegregatedRelation('relName')->where('col', '=', 'text'), // Reuse the method relation: 'relNameAsMethod' => $this->relNameAsMethod(...), 'relNameAsMethod' => fn(): HasOne => $this->relNameAsMethod(), // AVOID THIS BECAUSE IT IS NOT Closure and it will not work: 'relNameAsMethod' => [$this, 'relNameAsMethod'], // AVOID THIS 'relNameAsMethod' => fn(): HasOne => [$this, 'relNameAsMethod'](), // DO NOT USE IT LIKE THIS!: 'relNameAsMethod' => fn(): HasOne => $this->relNameAsMethod(...)(), // executes the relation inside the map. ]; }

And get the whole list by calling segregatedRelationList:

/** * Get the list of all currently identified relationship keys. * * This list includes: * 1. Explicitly defined relations from * @see segregatedRelationsDefinitionMap() * 2. Implicit method-based relations that have been "promoted" to the global * static map via @see resolveSegregatedRelationClosure() * * @param bool $discoverMethods If true, performs a one-time SLOW REFLECTION scan to identify and * promote all typed relationship methods to the global map. * * @note This list is usage-dependent when $discoverMethods is false. If true, the static * map is force-populated for the remainder of the request lifecycle. * THE FASTEST WAY for execution is to refactor all method relations by moving them into that map or * manually promote all method relations to segregated relations via: * @see segregatedRelationsDefinitionMap() * return [ * 'relNameAsMethod' => $this->relNameAsMethod(...) * ] * * @return string[] */
final public function segregatedRelationList(bool $discoverMethods = false): array
{ if ($discoverMethods) { $this->promoteMethodRelationsToSegregatedRelations(); } return \array_keys($this->thisSegregatedRelationDefinitionMap());
}
View more