Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/hrms.ncriptech.com/vendor/stancl/virtualcolumn/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
# Eloquent Virtual Column ## Installation Supports Laravel 9, 10, 11. ``` composer require stancl/virtualcolumn ``` ## Usage Use the `VirtualColumn` trait on your model: ```php use Illuminate\Database\Eloquent\Model; use Stancl\VirtualColumn\VirtualColumn; class MyModel extends Model { use VirtualColumn; public $guarded = []; public static function getCustomColumns(): array { return [ 'id', 'custom1', 'custom2', ]; } } ``` Create a migration: ```php public function up() { Schema::create('my_models', function (Blueprint $table) { $table->increments('id'); $table->string('custom1')->nullable(); $table->string('custom2')->nullable(); $table->json('data'); }); } ``` And store any data on your model: ```php $myModel = MyModel::create(['foo' => 'bar']); $myModel->update(['foo' => 'baz']); ```