<commit_before><?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Thread extends Model
{
    protected $table = 'threads';

    public function posts()
    {
        return $this->hasMany('App\Post');
    }

    public function poster()
    {
        return $this->hasOne('App\Post');
    }
}<commit_msg>Add getOP function to obtain first post, and replaced poster relationship with getPoster function<commit_after><?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Thread extends Model
{
    protected $table = 'threads';

    public function posts()
    {
        return $this->hasMany('App\Post');
    }

    /**
     * Fetch the first post within the thread
     * @return Post
     */
    public function getOP()
    {
        $op = Post::where('thread_id', $this->id)->first();
        return $op;
    }

    /**
     * Fetch the initial poster of the thread
     * @return User
     */
    public function getPoster()
    {
        $posterid = $this->getOP()->poster_id;
        $poster = User::where('id', $posterid)->first();
        return $poster;
    }
}
{'fraction_non_alphanumeric': 0.12769485903814262, 'fraction_numerical': 0.0, 'mean_word_length': 2.6798780487804876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2075163', 'n_tokens_mistral': 369, 'n_tokens_neox': 370, 'n_words': 92}