You are passing in a post not a point? The error even says so? Did you read the examples?
$point = Point::find(1);
// or via HasBadge trait method
$user->achievePoint($point);
Or does the PostApproved extend the base point? Show the class then
im facing issue with this new point package who can assit me please what am trying to do is give user point after they have succefully created a post https://github.com/ansezz/laravel-gamify
App\Models\User::achievePoint(): Argument #1 ($point) must be of type Ansezz\Gamify\Point, App\Models\Post given, called in C:\Users\ADEALA\Desktop\tribe-app\tribe\app\Http\Livewire\PostCreate.php on line 56
public function createPost()
{
if (auth()->check()) {
$this->validate();
$random = str_pad(mt_rand(1,999999),6,'0',STR_PAD_LEFT);
$post = Post::create([
'user_id' => auth()->user()->id,
'title' => $this->title,
'category_id' => $this->category,
'body' => $this->body,
'post_number' => $random,
'slug' => Str::slug($this->title) ?? null,
]);
$users = auth()->user();
$users->achievePoint( new PostApproved($post));
$image = $this->photo->storeAs('posts', str::random(30));
$post->image = $image;
$post->save();
session()->flash("message", "Featured image successfully uploaded");
preg_match_all('/(?<=#)(\w+)/mi', $this->body, $matchedTags, PREG_SET_ORDER, 0);
foreach ($matchedTags as $matchedTag) {
if (!$tag = Tag::where('name', $matchedTag[0])->first()) {
$tag = tag::create(['name' => $matchedTag[0]]);
}
$post->tags()->attach($tag->id);
$tag->addEnergy(1);
}
preg_match_all('/(?<=@)(\w+)/mi', $this->body, $matchedMentions, PREG_SET_ORDER, 0);
foreach ($matchedMentions as $matchedMention) {
optional(User::where('username', $matchedMention[0])->first(), function ($user) {
// $user->notify(new MentionsNotify($user));
});
}
// $users = auth()->user();
// $users->increment('points', 10);
session()->flash('success_message', 'Post was added successfully!');
$this->reset();
return redirect()->route('post.index');
}
abort(Response::HTTP_FORBIDDEN);
}
You are passing in a post not a point? The error even says so? Did you read the examples?
$point = Point::find(1);
// or via HasBadge trait method
$user->achievePoint($point);
Or does the PostApproved extend the base point? Show the class then
Please or to participate in this conversation.