Comments (9)
plz show me the App\Profile
used traits.
from laravel-follow.
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.
@abhi-cognitivo plz test on master branch.
from laravel-follow.
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_idfrom
profile_followerswhere
relation= follow and
profile_id= 1 and
followable_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.
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.
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.
@abhi-cognitivo a6962d6
from laravel-follow.
❤️
from laravel-follow.
Fantastic! thanks
from laravel-follow.
Related Issues (20)
- Getting same error in Model all the time HOT 7
- Error Traits HOT 9
- Get List of Followings users HOT 1
- config key typo HOT 2
- Question: How to send notification/email to user when they have a new follower? HOT 11
- get General error: 1 no such table: followables error HOT 12
- $user->followings not working properly HOT 6
- how to recover data from the "following" user? HOT 2
- Feature Request: Followers you know HOT 9
- Extending the model
- Trait "Overtrue\LaravelFollow\Traits\Followable" not found HOT 2
- Update for Laravel 10
- [ERROR] After running command - SSL Issues HOT 3
- php artisan vendor:publish does not publish the migration or config HOT 3
- Error after upgrade to 5.1.0 HOT 14
- wrong sample code in readme.
- Can't Get Following Model Data HOT 1
- getting "general error" when attempting to use UUIDs HOT 2
- sorry. please delete this issue
- has_followed没有实现 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-follow.