for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Arcanedev\LaravelAuth\Models\Traits;
/**
* Class Activatable
*
* @package Arcanedev\LaravelAuth\Traits
* @author ARCANEDEV <[email protected]>
* @property bool is_active
* @method bool save(array $options = [])
*/
trait Activatable
{
/* ------------------------------------------------------------------------------------------------
| CRUD Functions
| ------------------------------------------------------------------------------------------------
* Activate the model.
* @param bool $save
* @return bool
public function activate($save = true)
return $this->switchActive(true, $save);
}
* Deactivate the model.
public function deactivate($save = true)
return $this->switchActive(false, $save);
* Activate/deactivate the model.
* @param bool $active
protected function switchActive($active, $save = true)
$this->is_active = boolval($active);
return $save ? $this->save() : false;
| Check Functions
* Check if the model is active.
public function isActive()
return $this->is_active;