This question already has an answer here:
I have a problem with my function in laravel
I am trying to execute the following code:
public static function likePost($value)
{
$post_id = $value['post_id'];
$user_id = $value['user_id'];
if($value['liked'] == "1")
{
$model = new Like;
$model->fill($value);
$model->created = time();
if($model->save())
{
$post = Post::with('user')->where('id', '=', $value['post_id'])->get()->first();
$text = $post['user']['name']." ".Notification::TEXT_LIKE_POST;
Push::push($text, $value['post_id']);
}
}
else
{
Like::where('user_id', '=', $user_id)->where('post_id', '=' $post_id)->get()->first()->delete();
}
}
But I'm getting the following error: syntax error, unexpected '$post_id' (T_VARIABLE)
What is wrong with this function? Inside of the if the $post_id work fine, but in the else it don't work.
</div>