1. Go to this page and download the library: Download shipu/watchable 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/ */
shipu / watchable example snippets
activity()->log('Look, I logged something');
activity()
->on($anEloquentModel)
->data($storeWhatYouWantTo)
->log('Look, I logged something');
$lastLoggedActivity = Activity::all()->last();
$lastLoggedActivity->model; //returns an instance of an eloquent model
$lastLoggedActivity->causer; //returns an instance of your user model
$lastLoggedActivity->remarks; //returns 'Look, I logged something'
$user->name = 'updated name';
$user->save();
//updating the newsItem will cause the logging of an activity
$activity = Activity::all()->last();
$activity->remarks; //returns 'User Updated'
$activity->model; //returns the instance of NewsItem that was created
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('slug');
$table->string('status');
$table->integer('position');
$table->softDeletes();
// 1. Raw string, 3rd argument.
$table->partialUnique('slug', 'uniq_products_slug', 'deleted_at is null');
// 2. Raw string, chained.
$table->partialUnique('slug', 'uniq_products_slug')->where('deleted_at is null');
// 3. Closure — receives a real Illuminate\Database\Query\Builder. Safe for values
// from user input; bindings are inlined via Laravel's own binding-substitution
// logic (the same code behind Builder::toRawSql()), not string concatenation.
$table->partialUnique('slug', 'uniq_products_slug')
->where(fn ($query) => $query->whereNull('deleted_at'));
// Non-unique conditional index — same three forms.
$table->partialIndex(['status', 'position'], 'idx_products_listing')
->where(fn ($query) => $query->whereNull('deleted_at'));
// No predicate at all — still compiles as `create unique index`, never as a table
// CONSTRAINT, so (unlike Laravel's native ->unique()) it accepts expressions:
// Postgres constraint syntax only allows plain column names, no exceptions.
$table->partialUnique([new Expression('COALESCE(parent_id, 0)'), 'slug'], 'uniq_topic_slug_per_parent');
});
Schema::table('products', function (Blueprint $table) {
$table->dropIndex('uniq_products_slug');
});
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->decimal('subtotal', 10, 2);
$table->decimal('discount_amount', 10, 2)->default(0);
$table->decimal('total', 10, 2);
$table->check('total = subtotal - discount_amount AND total >= 0', 'chk_total');
});
Schema::table('orders', function (Blueprint $table) {
$table->dropCheck('chk_total');
});