GithubHelp home page GithubHelp logo

Comments (11)

duellsy avatar duellsy commented on August 16, 2024

currently no, open to pull requests on the dev branch for this though, sounds handy

from revisionable.

SuperlativeEntity avatar SuperlativeEntity commented on August 16, 2024

+1

from revisionable.

mmodler avatar mmodler commented on August 16, 2024

+1

Why closed?

from revisionable.

duellsy avatar duellsy commented on August 16, 2024

Closed since nobody decided it was important enough to work on, will re-open so someone can work on this and submit a pull request

from revisionable.

mmodler avatar mmodler commented on August 16, 2024

My workaround for now in my Basemodel:

public function revisionHistoryWithUser()
{
    return $this->morphMany('\MyAppName\Models\Revision', 'revisionable')->with('user');
}

from revisionable.

carcinocron avatar carcinocron commented on August 16, 2024

Is there a reason this doesn't work? (from Laravel docs)

$books = Book::all();

$books->load('author', 'publisher');

from revisionable.

warksit avatar warksit commented on August 16, 2024

Just to expand slightly on @mmodler response as it did lead me in the right direction.

Create a Revision class of your own extending \Venturecraft\Revisionable\Revision.
Add a true user relation:

    public function user(){
        return $this->belongsTo('User'); //Namespace as appropriate
    }

then add function revisionHistoryWithUser() as @mmodler said
If you already have your view set up remember to now reference user rather than userResponsible.

@InstanceOfMichael I don't believe that will work as userResponsible is not defined as a relationship of Revision.

from revisionable.

carcinocron avatar carcinocron commented on August 16, 2024

That seems likely, I think defining that use relationship was probably one of the first things I did.

from revisionable.

pr4xx avatar pr4xx commented on August 16, 2024

+1

from revisionable.

mavci avatar mavci commented on August 16, 2024

+1

from revisionable.

cuberinooo avatar cuberinooo commented on August 16, 2024

as @warksit pointed it out. You can make it more simple just by using the relation.

Extends Revision and put the following code:

public function user(){ return $this->belongsTo(User::class); }

In your application you can use it like $revision->user instead of $revision->userResponsible(). And just as relations you can do your eager load as you would do with eloquent models.
Btw if you load your revisions: do it like Revision::with(['revisionable','user'])

from revisionable.

Related Issues (20)

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.