Giter Site home page Giter Site logo

User reference about stream-laravel HOT 4 CLOSED

kallepyorala avatar kallepyorala commented on September 25, 2024
User reference

from stream-laravel.

Comments (4)

tbarbugli avatar tbarbugli commented on September 25, 2024

Good question.

You can customize how each field is populated when the activity is created. Note: the code snippets here are not tested but should give you a good idea of the general idea ;)

// here more code about the model class using the Activity trait ...

     public function userRef()
    {
        return "SU:${userId}";
    }

    public function activityActorMethodName()
    {
        return 'userRef';
    }

// ...

The same thing can be achieved in a cleaner way by using the PHP client:

$client->users()->createReference("john-doe");

You can retrieve the PHP client using the FeedManager facade:

FeedManager::getClient

from stream-laravel.

kallepyorala avatar kallepyorala commented on September 25, 2024

I think I tested that and got an exception because method declared in activityActorMethodName() should return instance of Eloquent relation, but I will test again.

from stream-laravel.

tbarbugli avatar tbarbugli commented on September 25, 2024

That is indeed very possible; an alternative approach is to implement activityActor for your model class. (and return the user ref as string)

from stream-laravel.

kallepyorala avatar kallepyorala commented on September 25, 2024

That does the job, I didn't think at all to overwrite that one, thanks @tbarbugli

from stream-laravel.

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.