<commit_before><?php

namespace App\DataTables;

use App\Feedback;
use App\Student;
use App\StudentSurvey;
use Illuminate\Database\Query\Builder;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Services\DataTable;

class StudentSurveyDataTable extends DataTable
{
    /**
     * Build DataTable class.
     *
     * @param mixed $query Results from query() method.
     * @return \Yajra\DataTables\DataTableAbstract
     */
    public function dataTable($query)
    {
        $dataTable = new EloquentDataTable($query);

        return $dataTable
            ->addColumn('action', 'student-survey.datatables.action')
            ->editColumn('student_id', function ($studentSurvey) {
                return view('student-survey.datatables.student', compact('studentSurvey'))->render();
            })
            ->filterColumn('student_id', function ($query, $keyword) {
                /* @var Builder|Feedback $query */
                $query->whereHas('student', function ($query) use ($keyword) {
                    /* @var Builder|Student $query */
                    $query->where('name', 'like', '%' . $keyword . '%')
                        ->orWhere('nid', 'like', '%' . $keyword . '%');
                });
            })
            ->addColumn('is_freshman', function ($studentSurvey) {
                /** @var Feedback $studentSurvey */
                return view('student-survey.datatables.is_freshman', compact('studentSurvey'))->render();
            })
            ->editColumn('comment', function ($studentSurvey) {
                return view('student-survey.datatables.comment', compact('studentSurvey'))->render();
            })
            ->escapeColumns([]);
    }

    /**
     * Get the query object to be processed by dataTables.
     *
     * @param StudentSurvey $model
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection
     */
    public function query(StudentSurvey $model)
    {
        return $model->newQuery()->with('student');
    }

    /**
     * Optional method if you want to use html builder.
     *<commit_msg>Fix phpDoc<commit_after><?php

namespace App\DataTables;

use App\Student;
use App\StudentSurvey;
use Illuminate\Database\Query\Builder;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Services\DataTable;

class StudentSurveyDataTable extends DataTable
{
    /**
     * Build DataTable class.
     *
     * @param mixed $query Results from query() method.
     * @return \Yajra\DataTables\DataTableAbstract
     */
    public function dataTable($query)
    {
        $dataTable = new EloquentDataTable($query);

        return $dataTable
            ->addColumn('action', 'student-survey.datatables.action')
            ->editColumn('student_id', function ($studentSurvey) {
                return view('student-survey.datatables.student', compact('studentSurvey'))->render();
            })
            ->filterColumn('student_id', function ($query, $keyword) {
                /* @var Builder|StudentSurvey $query */
                $query->whereHas('student', function ($query) use ($keyword) {
                    /* @var Builder|Student $query */
                    $query->where('name', 'like', '%' . $keyword . '%')
                        ->orWhere('nid', 'like', '%' . $keyword . '%');
                });
            })
            ->addColumn('is_freshman', function ($studentSurvey) {
                /** @var StudentSurvey $studentSurvey */
                return view('student-survey.datatables.is_freshman', compact('studentSurvey'))->render();
            })
            ->editColumn('comment', function ($studentSurvey) {
                return view('student-survey.datatables.comment', compact('studentSurvey'))->render();
            })
            ->escapeColumns([]);
    }

    /**
     * Get the query object to be processed by dataTables.
     *
     * @param StudentSurvey $model
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection
     */
    public function query(StudentSurvey $model)
    {
        return $model->newQuery()->with('student');
    }

    /**
     * Optional method if you want to use html builder.
     *
{'fraction_non_alphanumeric': 0.14148512532208948, 'fraction_numerical': 0.0, 'mean_word_length': 2.2871439568899152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '6426604', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1155, 'n_words': 225}