Constants

CREATED_AT

CREATED_AT

The name of the "created at" column.

UPDATED_AT

UPDATED_AT

The name of the "updated at" column.

Properties

$wordpressPrefix

$wordpressPrefix : boolean

Add wordpressPrefix table name

Type

boolean

$validation

$validation : boolean

Define whether you need to validate the data

Type

boolean

$baseTable

$baseTable : boolean

Use table base or current blog (MultiSite).

Type

boolean

$primaryKey

$primaryKey : string

The primary key for the model.

Type

string

$fillable

$fillable : array

The attributes that are mass assignable.

Type

array

$dates

$dates : array

The attributes that should be mutated to dates.

Type

array

Methods

getTable()

getTable() : string

Get the table associated with the model.

Returns

string

newEloquentBuilder()

newEloquentBuilder(\Illuminate\Database\Query\Builder  $query) : \Illuminate\Database\Eloquent\Builder|\MocaBonita\tools\eloquent\MbDatabaseEloquentBuilder

Create a new Eloquent query builder for the model.

Parameters

\Illuminate\Database\Query\Builder $query

Returns

\Illuminate\Database\Eloquent\Builder|\MocaBonita\tools\eloquent\MbDatabaseEloquentBuilder

createSchema()

createSchema(\Illuminate\Database\Schema\Blueprint  $table) 

Implement method to create schemas

Parameters

\Illuminate\Database\Schema\Blueprint $table

Throws

\Exception

createSchemaModel()

createSchemaModel(boolean  $deleteIfExists = false) 

Call createSchema when activating, deactivating or uninstalling plugin

Parameters

boolean $deleteIfExists

To recreate scheme

updateSchema()

updateSchema(\Illuminate\Database\Schema\Blueprint  $table) 

Implement method to update schemas

Parameters

\Illuminate\Database\Schema\Blueprint $table

Throws

\Exception

updateSchemaModel()

updateSchemaModel() 

Call updateSchema when activating, deactivating or uninstalling plugin

Throws

\Exception

dropSchemaModel()

dropSchemaModel() 

Call delete scheme

save()

save(array  $options = array()) : boolean

Save the model to the database.

Parameters

array $options

Throws

\MocaBonita\tools\MbException

Returns

boolean

getSchema()

getSchema() : \Illuminate\Database\Schema\Builder

Get TableSchema Builder

Returns

\Illuminate\Database\Schema\Builder

newPivot()

newPivot(\Illuminate\Database\Eloquent\Model  $parent, array  $attributes, string  $table, boolean  $exists, null  $using = null) : \MocaBonita\tools\eloquent\MbPivot

Create a new pivot model instance.

Parameters

\Illuminate\Database\Eloquent\Model $parent
array $attributes
string $table
boolean $exists
null $using

Returns

\MocaBonita\tools\eloquent\MbPivot

isBaseTable()

isBaseTable() : boolean

Returns

boolean

setBaseTable()

setBaseTable(boolean  $baseTable = true) 

Parameters

boolean $baseTable

meta()

meta() : \Illuminate\Database\Eloquent\Relations\HasMany

PostMeta relationship.

Returns

\Illuminate\Database\Eloquent\Relations\HasMany

type()

type(  $type) : \Illuminate\Database\Eloquent\Collection

Get a specific type of post.

Parameters

$type

Returns

\Illuminate\Database\Eloquent\Collection

attachFile()

attachFile(\Illuminate\Http\UploadedFile  $file, integer  $parent) : \MocaBonita\model\MbPost

Attach file in WordPress media

Parameters

\Illuminate\Http\UploadedFile $file
integer $parent

Throws

\MocaBonita\tools\MbException

Returns

\MocaBonita\model\MbPost

getWpdb()

getWpdb() : \wpdb

Wordpress DB Manager

Returns

\wpdb

validation()

validation(array  $attributes) : array|\MocaBonita\tools\validation\MbValidation|null

Implement method to validation model

Parameters

array $attributes

Returns

array|\MocaBonita\tools\validation\MbValidation|null

asDateTime()

asDateTime(mixed  $value) : \Carbon\Carbon

Return a timestamp as DateTime object.

Parameters

mixed $value

Returns

\Carbon\Carbon