PHP code example of jsefton / laravel-virtual-fields
1. Go to this page and download the library: Download jsefton/laravel-virtual-fields library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsefton / laravel-virtual-fields example snippets
use Illuminate\Database\Eloquent\Model;
use JSefton\VirtualFields\VirtualFields;
class Post extends Model
{
use VirtualFields;
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('{table}', function (Blueprint $table) {
$table->longText('data')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('{table}', function (Blueprint $table) {
$table->dropColumn(['data']);
});
}
$post = Post::find(1);
// Set a virtual field of sub_title
$post->sub_title = 'Example post sub title';
$post->save();
echo $post->sub_title;
// outputs: Example post sub title
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.