PHP code example of imagina / ihelpers-module

1. Go to this page and download the library: Download imagina/ihelpers-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

imagina / ihelpers-module example snippets


// config/app.php

'providers' => [
    ...
    Modules\Ihelpers\Other\ImResponseCache\ImResponseCacheServiceProvider::class,
];

// config/app.php

'aliases' => [
    ...
   'ResponseCache' => Modules\Ihelpers\Other\ImResponseCache::class,
];

   '    'EntityTransformer'=>[
         'otherEntity'=>[
           'path'=>'Modules\Iothermodule\Transformers\OtherEntityTransformer', //this is the transformer path
           'multiple'=>false, //if the relationship is one-to-many, multiple must be set to true
         ],
       ],
       ...
   ],   
   'relations' =>[
     'entity'=>[
       'otherEntity' => function () {
         return $this->hasOne(
           \Modules\Iothermodule\Entities\OtherEntity::class, 'model_id');
       },
     ],
     ...
   ],  
   

  use Modules\Ihelpers\Traits\Relationable;
  class Entity extends Model{
    use Relationable;
  

    use Modules\Ihelpers\Traits\Transformeable;
    class EntityTransformer extends JsonResource{
      use Transformeable;
  
bash
php artisan vendor:publish --provider="Modules\Ihelpers\Other\ImResponseCache\ImResponseCacheServiceProvider"
bash
php artisan pagecache:clear