• Resolved Habib

    (@habibjh)


    $subscriber = FluentCrm\App\Models\Subscriber::create(
    [
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]',
    'status' => 'subscribed',
    ]
    );

    I can’t add a new contact with the below method. It shows this fatal error – Call to undefined method FluentCrm\Framework\Database\Query\Builder::create().

    Please check the screenshot – https://prnt.sc/5jLBtTvyUeLj

    Can you please give me any solution?

    • This topic was modified 5 months ago by Habib.
Viewing 1 replies (of 1 total)
  • Plugin Author Shahjahan Jewel

    (@techjewel)

    To Create contact please use this API: https://developers.fluentcrm.com/global-functions/contact-api-function/

    $contactApi = FluentCrmApi('contacts');

    /*
    * Update/Insert a contact
    * You can create or update a contact in a single call
    */

    $data = [
    'first_name' => 'Jhon',
    'last_name' => 'Doe',
    'email' => '[email protected]', // requied
    'status' => 'pending',
    'tags' => [1,2,3, 'Dynamic Tag'], // tag ids/slugs/title as an array
    'lists' => [4, 'Dynamic List'] // list ids/slugs/title as an array,
    'detach_tags' => [6, 'another_tag'] // tag ids/slugs/title as an array,
    'detach_lists' => [10, 'list_slug'] // list ids/slugs/title as an array,
    'custom_values' => [
    'custom_field_slug_1' => 'custom_field_value_1',
    'custom_field_slug_2' => 'custom_field_value_2',
    ]
    ];

    $contact = $contactApi->createOrUpdate($data);

    // send a double opt-in email if the status is pending
    if($contact && $contact->status == 'pending') {
    $contact->sendDoubleOptinEmail();
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.