Skip to content

Instantly share code, notes, and snippets.

@ashishakya
Created June 30, 2022 05:26
Show Gist options
  • Select an option

  • Save ashishakya/ec327b8238e67a6bf1406eef57141aef to your computer and use it in GitHub Desktop.

Select an option

Save ashishakya/ec327b8238e67a6bf1406eef57141aef to your computer and use it in GitHub Desktop.
pankaj dai ram katha
<?php
namespace App\Transformers\Tenancy\LeadsCustomField;
use App\Models\Tenancy\LeadsCustomField;
use Illuminate\Support\Str;
use League\Fractal\TransformerAbstract;
/**
* Class LeadsCustomFieldListTransformer
* @package App\Transformers\Tenancy\Object
*/
class LeadsCustomFieldListTransformer extends TransformerAbstract
{
protected $defaultIncludes = ["relation"]; // key ko name
protected $availableIncludes = [""]; //request gare pachi tanney
/**
* @param LeadsCustomField $leadsCustomField
*
* @return array
*/
public function transform(LeadsCustomField $leadsCustomField): array
{
return [
"id" => $leadsCustomField->id,
"field_type" => $leadsCustomField->field_type,
"field_label" => $leadsCustomField->field_label,
"is_required" => filter_var($leadsCustomField->is_mandatory, FILTER_VALIDATE_BOOLEAN),
"actions" => [
"edit" => !$leadsCustomField->isUsed(),
"delete" => !$leadsCustomField->isUsed(),
],
"relation"=> [] // default if tala bata kei aayena bhane
];
}
// public function includeRelation($leadsCustomField){ here Relation is key from mathi property
//// relation item ho ki item
//// cif colelction
// return $this->collection($leadsCustomField->relation, new tranform());
//
//// if item
// return $this->item($leadsCustomField->relation, new tranform());
//
// }
}
// chain -> wrap always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment