PHP code example of latevaweb / laravel-custom-properties
1. Go to this page and download the library: Download latevaweb/laravel-custom-properties 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/ */
latevaweb / laravel-custom-properties example snippets
$customer = new Customer; // An Eloquent model
$customer
->setCustomProperty('foo', 'bar')
->setCustomProperty('foo2', 'bar2')
->save();
$customer->hasCustomProperty('foo'); // Returns 'true'
$customer->getCustomProperty('foo'); // returns 'bar'
$customer->forgetCustomProperty('foo'); // removes field 'foo' from model array
// Don't forget to persist it!
$customer->save();
use Illuminate\Database\Eloquent\Model;
use LaTevaWeb\CustomProperties\HasCustomProperties;
class NewsItem extends Model
{
use HasCustomProperties;
}
Schema::table('your_table', function (Blueprint $table) {
$table->json('custom_properties')->nullable();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.