Skip to content

Instantly share code, notes, and snippets.

@ollieread
Last active August 29, 2015 14:06
Show Gist options
  • Save ollieread/386f063f1d4b41c6c7f1 to your computer and use it in GitHub Desktop.
Save ollieread/386f063f1d4b41c6c7f1 to your computer and use it in GitHub Desktop.
<?php
class Activity
{
public static function log(Model $user, Model $subject, $action)
{
$log = $this->user->logs()-.>create(['action'] => $action]);
$log->subject()->save($subject);
}
}
<?php
class create_logging_table extends Migration
{
public function up()
{
Schema::create('activity_logging', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id', false);
$table->morphs('subject');
$table->string('action');
$table->timestamps();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment