# Subject Model

DB Table Name {wp_db_prefix}_fc_meta
Schema Check Schema
Source File fluent-crm/app/Models/Subject.php
Name Space FluentCrm\App\Models
Class FluentCrm\App\Models\Subject

# Attributes

Attribute Data Type Comment
id Integer
object_type String
object_id Integer
key String
value Text
created_at Date Time
updated_at Date Time

# Usage

Please check Model Basic for Common methods.

# Accessing Attributes


$subject = FluentCrm\App\Models\Subject::find(1);

$subject->id; // returns id
$subject->value; // returns subject value
.......
1
2
3
4
5
6

# Fillable Attributes


'object_type',
'object_id',
'key',
'value'
1
2
3
4
5

# Relations

This model has the following relationships that you can use

# campaign

Access the associated campaign of a model

  • return FluentCrm\App\Models\Campaign Model Collections

# Example:

// Accessing Campaign
$campaign = $subject->campaign;

// For Filtering by campaign relationship

// Get Subjects which has campaign title 'My First Campaign'
$subjects = FluentCrm\App\Models\Subject::whereHas('campaign', function($query) {
    $query->where('title', 'My First Campaign');
})->get();

// Get Subjects which does not have campaign title 'My First Campaign'
$subjects = FluentCrm\App\Models\Subject::whereDoesntHave('campaign', function($query) {
    $query->where('title', 'My First Campaign');
})->get();

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

# emails

Access the associated emails of a model

  • return FluentCrm\App\Models\CampaignEmail Model Collections

# Example:

// Accessing Campaign
$emails = $subject->emails;

// For Filtering by emails relationship

// Get Subjects which has emails email_subject 'Hello world'
$subjects = FluentCrm\App\Models\Subject::whereHas('emails', function($query) {
    $query->where('email_subject', 'Hello world');
})->get();

// Get Subjects which does not have emails email_subject 'Hello world'
$subjects = FluentCrm\App\Models\Subject::whereDoesntHave('emails', function($query) {
    $query->where('email_subject', 'Hello world');
})->get();

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15