GithubHelp home page GithubHelp logo

Comments (9)

overtrue avatar overtrue commented on May 29, 2024

plz show me the App\Profile used traits.

from laravel-follow.

ablishek avatar ablishek commented on May 29, 2024

Hi, thanks for your quick response...

use Overtrue\LaravelFollow\Traits\CanFollow;
use Overtrue\LaravelFollow\Traits\CanBeFollowed;

class Profile extends Model
{
use ..., CanFollow, CanBeFollowed;
}

I have both a Profile and a User table. This is because a Profile can be a user and not at the same time, such as a brand or celebrity profile for example.

This is the last line that hits before the Exception mentioned above.

    public static function attachPivotsFromRelation(MorphToMany $morph, $targets, $class)
    {
        return self::formatTargets($targets, $class, [
            'relation' => self::getRelationTypeFromRelation($morph), //// <-- This is Causing the problem
            'created_at' => Carbon::now()->format(config('follow.date_format', 'Y-m-d H:i:s')),
        ]);
    }

I have updated the code try to get it to work with User table and Profile but still no use. Please any help would be greatly appreciated!

from laravel-follow.

overtrue avatar overtrue commented on May 29, 2024

@abhi-cognitivo plz test on master branch.

from laravel-follow.

ablishek avatar ablishek commented on May 29, 2024

Thanks for your quick reply. The original problem now seems to work, but I am getting a problem with the sql query being fired.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'profile_id' in 'where clause' (SQL: select followable_idfromprofile_followerswhererelation= follow andprofile_id= 1 andfollowable_type = App\Profile)

I have noticed you updated the Migration File. I am now running the installation code again to get the new migration file.

from laravel-follow.

ablishek avatar ablishek commented on May 29, 2024

Ok, so I checked your new code, and it seems that the

$table->unsignedInteger('user_id');

is hard coded but you are dynamically calling the column and thus it is showing profile_id.
This code would work perfectly if the table was user, but not so much if you change the table name.

Could you change this line
$table->unsignedInteger('user_id');
to
$table->unsignedInteger('follow.users_table_primary_key', 'user_id');

This way your config file create the appropriate name for the column and table being referenced. Not that _users_table_primary_key is really id, and we need table_name + _ + id

from laravel-follow.

ablishek avatar ablishek commented on May 29, 2024

Fyi, I manually changed the migration file to reflect profile_id and it worked flawless. So if you could update that last part I think you would have a really configurable following package.

Thanks for your help!

from laravel-follow.

overtrue avatar overtrue commented on May 29, 2024

@abhi-cognitivo a6962d6

from laravel-follow.

overtrue avatar overtrue commented on May 29, 2024

❤️

from laravel-follow.

ablishek avatar ablishek commented on May 29, 2024

Fantastic! thanks

from laravel-follow.

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.