Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for lead_products when saving a lead #116

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require __DIR__ . '/vendor/autoload.php';

$access_token = 'GUFBU8ZDGRFiX5q-Xt8nzwSuO6VzXb6zBM_IVHQqQd_Y4pAnjT6PtKkU324OROqt'; # testing program builder key
$access_token = '<ACCESS_TOKEN>'; # testing program builder key

$connection = new Eduframe\Connection();

Expand All @@ -14,10 +14,10 @@
$data = [];

// With include its possible to include nested relations.
$data['products'] = $client->catalog_products()->all(['include' => 'labels']);
$data['variants'] = $client->catalog_variants()->get();

// To get teachers pass the correct role
$data['teachers'] = $client->teachers()->all();
$data['teachers'] = $client->teachers()->get();

// Create a new lead
$lead = $client->leads();
Expand All @@ -32,9 +32,9 @@
'city' => 'Eindhoven',
'country' => 'NL',
]);
$lead->courses_leads = [$client->lead_interests([
"course_id" => 133,
"planned_course_id" => null
$lead->lead_products = [$client->lead_products([
"catalog_product_id" => 123,
"catalog_variant_id" => 456,
])];

$lead->save();
Expand Down
9 changes: 9 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Eduframe\Resources\Label;
use Eduframe\Resources\Lead;
use Eduframe\Resources\LeadInterest;
use Eduframe\Resources\LeadProduct;
use Eduframe\Resources\Location;
use Eduframe\Resources\Meeting;
use Eduframe\Resources\Variant;
Expand Down Expand Up @@ -155,6 +156,14 @@ public function lead_interests($attributes = []) {
return new LeadInterest($this->connection, $attributes);
}

/**
* @param array $attributes
* @return \Eduframe\Resources\LeadProduct
*/
public function lead_products($attributes = []) {
return new LeadProduct($this->connection, $attributes);
}

/**
* @param array $attributes
* @return \Eduframe\Resources\Meeting
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Lead extends Resource
'address',
'labels',
'courses_leads',
'lead_products',
'updated_at',
'created_at'
];
Expand Down Expand Up @@ -67,5 +68,9 @@ class Lead extends Resource
'entity' => LeadInterest::class,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
],
'lead_products' => [
'entity' => LeadProduct::class,
'type' => self::NESTING_TYPE_NESTED_OBJECTS,
],
];
}
32 changes: 32 additions & 0 deletions src/Resources/LeadProduct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Eduframe\Resources;

use Eduframe\Resource;

class LeadProduct extends Resource
{

/**
* @var array
*/
protected $fillable = [
'catalog_product_id',
'catalog_variant_id'
];

/**
* @var string
*/
protected $endpoint = 'lead_products';

/**
* @var string
*/
protected $model_name = 'LeadProduct';

/**
* @var string
*/
protected $namespace = 'lead_products';
}
Loading