Giter Site home page Giter Site logo

culpa's People

Contributors

carnevalle avatar rmasters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

culpa's Issues

Custom events

Use-case I've just come across is having a nullable datetime field, that once set would be nice to automatically assign who set it (separate from updated_at). E.g.:

$table->datetime('scheduled_at')->nullable();
$table->integer('scheduled_by_id')->unsigned();

$table->foreign('scheduled_by_id')->references('id')->on('users');

Potential model syntax:

class Broadcast extends Model {
protected $blameable = ['created'];
protected $blameable_extra = ['scheduled_at' => 'scheduled_by_id'];
}

Then setting scheduled_at sets scheduled_by_id to the current user.

Schema builder helpers

A nice-to-have if it's possible to add these - emulate the timestamps() helper for schema building:

Schema::create('comments', function($table) {
    $table->increments('id');

    $table->createdBy();
    $table->updatedBy();
    $table->deletedBy();
});

Aliasing to something like:

$table->integer('created_by_id')->unsigned();
$table->foreign('created_by_id')->references('id')->on(Config::get('culpa::users.table'));

Cannot eager load users with trashed

Might be a Laravel issue, the following does not work:

class Post extends Eloquent {
    public function createdBy() {
        // Culpa\CreatedBy
        return $this->belongsTo('User')->withTrashed();
    }
}

Post::with('createdBy')->get();

Results in "Invalid argument supplied for foreach()" in Illuminate/Database/Eloquent/Builder.php:388 ($this->query->wheres is null).

Some level of 5.3 compatability

While traits are PHP 5.4 and above, we still have a lot of people on 5.3 (even if it is EOL soonish).

It may be possible to pull the set-current-user-automatically parts into model hooks that are applied to all model events. So while 5.3 users would still have to define methods like createdBy(), updatedBy() on their models, the automatic-set part could be picked up automatically (I think the only user change would be making Model::$blameable public rather than protected).

deleted_by_id not being updated upon delete()

Hello, this is an amazing package I must say, but I'm having trouble to have the deleted_by_id field which is not being set after a softdelete. I can see that the delete_at field is updated as the updated_by_id, but not the deleted_by_id. I'm using the most recent version of Laravel:

"laravel/framework": "4.2.*",
"rmasters/culpa": "dev-master"

For my host I'm using the Laravel's Homestead via vagrant.

Any thoughts?

Appreciate your work and feedback! :)

deleted_by not set to null on restoring

Hi could you please add

    public function restoring(Model $model) {
        $model->{$this->getColumn($model, 'deleted')} = null;
    }

to the BlameableObserver, in order to also restore the deleted_by column when restoring a soft-deleted model

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.