233 lines
5.0 KiB
XML
233 lines
5.0 KiB
XML
<snippet>
|
|
<content><![CDATA[
|
|
use App\Events\${1:Model}Created;
|
|
use App\Events\${1:Model}Creating;
|
|
use App\Events\${1:Model}Deleted;
|
|
use App\Events\${1:Model}Deleting;
|
|
use App\Events\${1:Model}Deleting;
|
|
use App\Events\${1:Model}Replicating;
|
|
use App\Events\${1:Model}Restored;
|
|
use App\Events\${1:Model}Restoring;
|
|
use App\Events\${1:Model}Retrieved;
|
|
use App\Events\${1:Model}Saved;
|
|
use App\Events\${1:Model}Saving;
|
|
use App\Events\${1:Model}Updated;
|
|
use App\Events\${1:Model}Updating;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Prunable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Laravel\Scout\Searchable;
|
|
|
|
use Prunable;
|
|
use Searchable;
|
|
|
|
/** @var string */
|
|
protected \$table = '';
|
|
|
|
/** @var array<int,string> */
|
|
protected \$fillable = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$hidden = [];
|
|
|
|
/** @var array<string,string> */
|
|
protected \$casts = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$dates = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$appends = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$with = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$touches = [];
|
|
|
|
/** @var array<int,string> */
|
|
protected \$dispatchesEvents = [
|
|
//'retrieved' => ${1:Model}Retrieved::class,
|
|
//'creating' => ${1:Model}Creating::class,
|
|
//'created' => ${1:Model}Created::class,
|
|
//'updating' => ${1:Model}Updating::class,
|
|
//'updated' => ${1:Model}Updated::class,
|
|
//'deleting' => ${1:Model}Deleting::class,
|
|
//'deleted' => ${1:Model}Deleted::class,
|
|
//'deleting' => ${1:Model}Deleting::class,
|
|
//'saving' => ${1:Model}Saving::class,
|
|
//'saved' => ${1:Model}Saved::class,
|
|
//'restoring' => ${1:Model}Restoring::class,
|
|
//'restored' => ${1:Model}Restored::class,
|
|
//'replicating' => ${1:Model}Replicating::class,
|
|
];
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Class Constants
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Custom/Private Methods
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
/**
|
|
* Get the prunable model query.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Builder
|
|
*/
|
|
public function prunable(): Builder
|
|
{
|
|
// return static::where('deleted_at', '<=', now()->subMonth());
|
|
}
|
|
|
|
/**
|
|
* Prepare the model for pruning.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function pruning(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the value used to index the model.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getScoutKey()
|
|
{
|
|
return \$this->id;
|
|
}
|
|
|
|
/**
|
|
* Get the key name used to index the model.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getScoutKeyName(): string
|
|
{
|
|
return 'id';
|
|
}
|
|
|
|
/**
|
|
* Get the name of the index associated with the model.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return string
|
|
*/
|
|
public function searchableAs(): string
|
|
{
|
|
return 'prefix_models_index';
|
|
}
|
|
|
|
/**
|
|
* Get the indexable data array for the model.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return array
|
|
*/
|
|
public function toSearchableArray(): array
|
|
{
|
|
\$payload = \$this->toArray();
|
|
|
|
// modify here...
|
|
|
|
return \$payload;
|
|
}
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Accessors
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
/**
|
|
* An accessor.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
|
*/
|
|
protected function attrName(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn (\$value, \$attributes) => \$attributes['foo'],
|
|
set: fn (\$value, \$attributes) => \$attributes['foo'],
|
|
);
|
|
}
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Mutators
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Scopes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
/**
|
|
|--------------------------------------------------------------------------
|
|
| Relationships
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
/**
|
|
* Something relationship.
|
|
*
|
|
* @package App\Models\${1:Model}
|
|
* @since 1.0.0
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function something(): BelongsTo
|
|
{
|
|
return \$this->belongsTo(
|
|
related: Something::class,
|
|
foreignKey: 'something_id',
|
|
);
|
|
}
|
|
]]></content>
|
|
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
|
<tabTrigger>laramodel</tabTrigger>
|
|
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
|
<!-- <scope>source.python</scope> -->
|
|
</snippet>
|