<commit_before><?php namespace Indikator\News\Models;

use Model;
use File;
use App;
use DB;
use Mail;

class Posts extends Model
{
    use \October\Rain\Database\Traits\Sluggable;
    use \October\Rain\Database\Traits\Validation;

    public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel'];

    protected $table = 'news_posts';

    public $rules = [
        'title'   => 'required|between:1,100',
        'slug'    => ['between:1,100', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i'],
        'content' => 'required',
        'status'  => 'required|between:1,3|numeric'
    ];

    protected $slugs = ['slug' => 'title'];

    public $translatable = ['title', 'introductory', 'content'];

    protected $dates = ['published_at'];

    public function beforeCreate()
    {
        $this->statistics = 0;

        if ($this->published_at == '') {
            $this->published_at = date('Y-m-d H:i:00');
        }
    }

    public function beforeUpdate()
    {
        unset($this->statistics);
    }

    public function beforeSave()
    {
        if ($this->send && $this->send != '') {
            $locale = App::getLocale();

            if (!File::exists('plugins/indikator/news/views/mail/email_'.$locale.'.htm')) {
                $locale = 'en';
            }

            $users = DB::table('news_subscribers')->get();

            foreach ($users as $user) {
                $params = [
                    'name'  => $user->name,
                    'email' => $user->email,
                    'title' => $this->title,
                    'slug'  => $this->slug,
                    'introductory' => $this->introductory,
                    'content' => $this->content,
                    'image'   => $this->image
                ];

                $this->email = $user->email;
                $this->name = $user->name;

                Mail::send('indikator.news::mail.email_'.$locale, $params, function($message) {
                    $message->to($this->email, $this->name)->subject($this->title);
                });

                DB::table('news_subscribers')->where('id', $user->id)->update(array('statistics' => ($user->statistics + 1)));
            }

            unset($this->email, $this->name);
        }

        if ($this->send) {
            $this->send = 1;
        }
        else {
            $this->send = 2;
        }
    }
}
<commit_msg>Minor change<commit_after><?php namespace Indikator\News\Models;

use Model;
use File;
use App;
use DB;
use Mail;

class Posts extends Model
{
    use \October\Rain\Database\Traits\Sluggable;
    use \October\Rain\Database\Traits\Validation;

    public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel'];

    protected $table = 'news_posts';

    public $rules = [
        'title'   => 'required|between:1,100',
        'slug'    => ['between:1,100', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i'],
        'content' => 'required',
        'status'  => 'required|between:1,3|numeric'
    ];

    protected $slugs = ['slug' => 'title'];

    public $translatable = ['title', 'introductory', 'content'];

    protected $dates = ['published_at'];

    public function beforeCreate()
    {
        $this->statistics = 0;

        if ($this->published_at == '') {
            $this->published_at = date('Y-m-d H:i:00');
        }
    }

    public function beforeUpdate()
    {
        unset($this->statistics);
    }

    public function beforeSave()
    {
        if ($this->send && $this->send != '') {
            $locale = App::getLocale();

            if (!File::exists('plugins/indikator/news/views/mail/email_'.$locale.'.htm')) {
                $locale = 'en';
            }

            $users = DB::table('news_subscribers')->get();

            foreach ($users as $user) {
                $params = [
                    'name'  => $user->name,
                    'email' => $user->email,
                    'title' => $this->title,
                    'slug'  => $this->slug,
                    'introductory' => $this->introductory,
                    'content' => $this->content,
                    'image'   => $this->image
                ];

                $this->email = $user->email;
                $this->name = $user->name;

                Mail::send('indikator.news::mail.email_'.$locale, $params, function($message) {
                    $message->to($this->email, $this->name)->subject($this->title);
                });

                DB::table('news_subscribers')->where('id', $user->id)->update(['statistics' => ($user->statistics + 1)]);
            }

            unset($this->email, $this->name);
        }

        if ($this->send) {
            $this->send = 1;
        }
        else {
            $this->send = 2;
        }
    }
}

{'fraction_non_alphanumeric': 0.18558860494344365, 'fraction_numerical': 0.00754084625052367, 'mean_word_length': 1.719248291571754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, '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': '2175051', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1419, 'n_words': 239}