1. Go to this page and download the library: Download rulr/laravel-authored 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/ */
rulr / laravel-authored example snippets
use Illuminate\Database\Eloquent\Model;
use Rulr\Authored\Traits\HasAuthor;
class Post extends Model
{
use HasAuthor;
}
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->authored(); // Automatically adds created_by and updated_by fields
$table->timestamps();
});
$post = Post::create(['title' => 'First Post']);
$post->update(['title' => 'Updated Title']);
// Outputs the user ID who created the post
echo $post->created_by;
// Outputs the user ID who last updated the post
echo $post->updated_by;