laravel-acquaintances icon indicating copy to clipboard operation
laravel-acquaintances copied to clipboard

WIP: `CanBeActor` trait.

Open Necmttn opened this issue 4 years ago • 5 comments

Hey!

While implementing rating in my platform I notice there's some missing feature. First of all, let me explain why we need another trait: existing traits allow us to make easily 2 point interactions where users interact with something. this is all good use case but when you would like to implement something like the collective score for the provider.

Case example.

there's consumer, job, and the provider you would like to give rate to provider but if you directly rate the provider without mid entity you can only do that once. which is game blocker;

A better way to implement this would be user rates job and someone gets credits from it. so introduce nullableMorph('actor') in interactions table. where you can define who the actor getting credits from.

through this,

the provider could have an average rating base on the jobs he has done. the consumer could have an average rating base on the jobs created.

I don't think this branch is mature enough to merge in yet but would love to take opinions.

Cheers 🍻

example method on Models\User.php

    public function getJobSuccessRate()
    {
        $totalJobSuccessRate = $this->getRatesVia(
            [Job::class]
        )->average(
            'relation_value'
        );
        return Interaction::numberToReadable(
            $totalJobSuccessRate
        );
    }

an example method to rate

        $jobSession->job->author->rate(
            $jobSession,
            5,
            JobSession::RATING_GENERAL,
            null,
            $jobSession->developer
        );

Necmttn avatar Apr 20 '21 08:04 Necmttn

In case of confirmation; I would love to have someone help me to add the documentation part. This could be a nice first-contribute case.

Necmttn avatar Apr 20 '21 08:04 Necmttn

WOW! this is a big one, thanks for your time and efforts, give me sometime to examine it extensively

Thanks again!

mkwsra avatar Apr 21 '21 00:04 mkwsra

Any feedback on this ?

Necmttn avatar May 05 '21 12:05 Necmttn

So sorry for the late reply, please give me sometime as I am about to finish a very heavy work and be totally free to maintain this package again 😍

mkwsra avatar May 23 '21 16:05 mkwsra

@mkwsra thank you for this beautiful package of yours.

@Necmttn I am a newbie with this package too and I just digged in with the package just recently. I assume that the actor has a migration? but I cant see any.

ronssij avatar Mar 14 '22 03:03 ronssij

simply bro @Necmttn put the rating trait on the job instead of provider where consumer can rate each job (job related to provider)....

HMDagher avatar Nov 21 '23 16:11 HMDagher

It seems like the content is outdated, and I do not recall the context. Therefore, I am closing the PR.

Necmttn avatar Nov 25 '23 00:11 Necmttn