DB update not working - Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically

Posted 1 month ago by ChrisF79

I'm running a simple script to count pageviews. It pulls the pageviews, increments the number, then tries to update the record. However, I'm getting the error in the subject line.

        $views = wp_popularpostsdata::where('postid', '=', $data[0]['id'])->first()->toArray();
        $newviews = $views['pageviews']+1;
        $postid = $views['postid'];

        $query = "update wp_popularpostsdata set pageviews = '$newviews' where postid = $postid";
        $newviews = wp_popularpostsdata::update($query);

        return view('layouts.blog')->withData($data);

I'm embarrassed at how easy this should be but I'm stuck!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.