Comments (5)
It looks like you don't have user relation setup on Post
model
class Post extends Model
...
public function user() {
return $this->belongsTo('App\User');
}
}
please check and it should work
from laravel-gamify.
I've updated my code, but it doesn't work yet
$get_content = $request->input('content');
$user_id = Auth::user()->id;
$post = $user->posts()->create(array(
'content' => $get_content,
'user_id' => $user_id
));
givePoint(new PostCreated($post));
from laravel-gamify.
Please share your PostCreated point class
from laravel-gamify.
I didn't change the base of the PostCreated Class, as mentioned in the readme file.
<?php
namespace App\Gamify\Points;
use QCod\Gamify\PointType;
class PostCreated extends PointType
{
/**
* Number of points
*
* @var int
*/
public $points = 20;
/**
* Point constructor
*
* @param $subject
*/
public function __construct($subject)
{
$this->subject = $subject;
}
/**
* User who will be receive points
*
* @return mixed
*/
public function payee()
{
return $this->getSubject()->user;
}
}
$this->getSubject()->user return "null" value
$this return :
PostCreated {#996 ▼ +points: 20 #payee: "user" #subject: Posts {#962 ▼ #table: "posts" #fillable: array:4 [▶] #connection: "mysql" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: true #attributes: array:5 [▶] #original: array:5 [▶] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #guarded: array:1 [▶] } }
from laravel-gamify.
It works, i already have a function with users but called "Users" and not "user"
Thanks for your help !
from laravel-gamify.
Related Issues (20)
- Give points when badge is earned? HOT 1
- Feature: Morph support for Payee HOT 2
- Is this package still being maintained? HOT 2
- Can we extend the badge qualifier HOT 1
- Payee is not getting the user parameter HOT 3
- Laravel 8 Support HOT 1
- payee() method must return a model which will get the points HOT 3
- #ASK - How to call Notifications Got Awards
- From postaman ok, from webapp error HOT 2
- Work with the specific payee (not subject's user) HOT 4
- Use without Badge If your app doesn't need Badges you should just use HasReputations trait instead of Gamify. HOT 1
- Remove ShouldBroadcast from ReputationChanged event HOT 1
- Laravel octane
- Support Laravel 9.0 ? HOT 1
- How can I turn off the Info Logging HOT 1
- Populating meta column
- Can't give point to User HOT 1
- Give Points to another User HOT 1
- Leaderboard Position
- undoPoint() is not working HOT 1
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-gamify.