PHP code example of limanweb / eloquent-extensions
1. Go to this page and download the library: Download limanweb/eloquent-extensions 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/ */
limanweb / eloquent-extensions example snippets
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
...
// add userstamps fields
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
// if SoftDeletes trait will be used in model then add deleted_by field
// $table->bigInteger('deleted_by')->nullable();
});
}
...
}
...
use Limanweb\EloquentExt\Models\Concerns\HasUserstamps; // (1) declare
class User extends Authenticatable
{
use Notifiable;
use HasUserstamps; // (2) use trait in the model
public $userstamps = true; // (3) enable userstamps
...
}
...
use Limanweb\EloquentExt\Models\Concerns\HasCompositePrimaryKey; // (1) declare trait
class Example extends Model
{
use HasCompositePrimaryKey; // (2) use trait in the model
public $incrementing = false; // (3)
protected $primaryKey = ['part1', 'part2']; // (4)
...
}