# 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
```php
$subject = FluentCrm\App\Models\Subject::find(1);
$subject->id; // returns id
$subject->value; // returns subject value
.......
```
## Fillable Attributes
```php
'object_type',
'object_id',
'key',
'value'
```
## 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:
```php
// 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();
```
### emails
Access the associated emails of a model
- return `FluentCrm\App\Models\CampaignEmail` Model Collections
#### Example:
```php
// 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();
```