PHP code example of jlorente / laravel-identitystamps
1. Go to this page and download the library: Download jlorente/laravel-identitystamps 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/ */
jlorente / laravel-identitystamps example snippets
class MyMigration extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('my_table', function (Blueprint $table) {
$table->increments('id');
$table->string('my_field');
$table->timestamps();
$table->identityStamps();
});
}
}
class MyMigration extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('my_field');
$table->timestamps();
$table->identityStamps();
$table->softDeletes();
$table->softDeletesIdentityStamps();
});
}
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;
class Product extends Model
{
use IdentityStamps,
SoftDeletes;
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;
class Product extends Model
{
use IdentityStamps,
SoftDeletes;
const CREATED_BY = 'my_custom_identity_creation_field';
const UPDATED_BY = 'my_custom_identity_update_field';
const DELETED_BY = 'my_custom_identity_deletion_field';
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;
class Product extends Model
{
use IdentityStamps,
SoftDeletes;
public function getCreatedByColumn()
{
return 'my_custom_identity_creation_field';
}
public function getUpdatedByColumn()
{
return 'my_custom_identity_update_field';
}
public function getDeletedByColumn()
{
return 'my_custom_identity_deletion_field';
}
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;
class Product extends Model
{
use IdentityStamps,
SoftDeletes;
public function getIdentityStampValue()
{
return Auth::user() ? Auth::user()->email : null;
}
}
bash
$ php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.