Collaboration.php
1 month ago
CollaborationComment.php
1 month ago
CollaborationCommentSeen.php
1 month ago
CollaborationConnected.php
1 month ago
CollaborationSent.php
1 month ago
Collection.php
6 days ago
CollectionItem.php
1 month ago
Form.php
6 days ago
FormData.php
6 days ago
Media.php
1 month ago
Page.php
6 days ago
Post.php
1 month ago
PostMeta.php
2 weeks ago
Reference.php
1 month ago
Term.php
1 month ago
TermMeta.php
1 month ago
TermTaxonomy.php
1 month ago
User.php
1 month ago
UserMeta.php
1 month ago
Form.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Models; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use Kirki\Framework\Database\Query\Model; |
| 8 | |
| 9 | /** |
| 10 | * Form model — maps to the `kirki_forms` table (KIRKI_FORM_TABLE). |
| 11 | * |
| 12 | * One row per form element rendered on a post/page. Submitted entries are |
| 13 | * stored in the related `kirki_forms_data` table via {@see FormData}. |
| 14 | */ |
| 15 | class Form extends Model |
| 16 | { |
| 17 | /** |
| 18 | * The database table (without prefix; the connection adds it). |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | protected $table = 'kirki_forms'; |
| 23 | |
| 24 | /** |
| 25 | * The primary key column. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | protected $primary_key = 'id'; |
| 30 | |
| 31 | /** |
| 32 | * created_at / updated_at are handled by the table's CURRENT_TIMESTAMP |
| 33 | * |
| 34 | * @var bool |
| 35 | */ |
| 36 | protected $timestamps = true; |
| 37 | |
| 38 | /** |
| 39 | * Mass-assignable attributes. |
| 40 | * |
| 41 | * @var array |
| 42 | */ |
| 43 | protected $fillable = [ |
| 44 | 'post_id', |
| 45 | 'form_ele_id', |
| 46 | 'name', |
| 47 | ]; |
| 48 | |
| 49 | /** |
| 50 | * Attribute casts. |
| 51 | * |
| 52 | * @var array |
| 53 | */ |
| 54 | protected $casts = [ |
| 55 | 'id' => 'integer', |
| 56 | 'post_id' => 'integer', |
| 57 | ]; |
| 58 | |
| 59 | /** |
| 60 | * Submitted entries for this form. |
| 61 | * |
| 62 | * @return \Kirki\Framework\Database\Query\Relations\HasMany |
| 63 | */ |
| 64 | public function submissions() |
| 65 | { |
| 66 | return $this->has_many(FormData::class, 'form_id', 'id'); |
| 67 | } |
| 68 | } |
| 69 |