HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/rentman.komma.pro/app/Komma/Questions/QuestionService.php
<?php

namespace Komma\Questions;

use Illuminate\Support\Collection;
use Komma\Questions\Models\Question;


/**
 *
 * @author      Pascal Lemmen <pascal@komma.pro>
 * @copyright   (c) 2012-2016, Komma Mediadesign
 */
class QuestionService
{
    /**
     * This method gets the questions with an IN
     *
     * @param $field | string, field for the in
     * @param $values | array, values for the in
     * @return mixed
     */
    public function getQuestionsIn($field, $values)
    {
        //Only get the active Questions
        $questions = Question::where('active', '=', 1)
            //Where in with field and values
            ->whereIn($field, $values)
            //Also load the translation
            ->with('translation')
            ->with('images')
            ->get()
            ->keyBy($field);

        return $questions; 
    }

    /**
     * This method invokes the getQuestionsIn
     * With code_name as field
     *
     * @param $code_names
     * @return mixed
     */
    public function getQuestionsByCodeName($code_names)
    {
        return $this->getQuestionsIn('code_name', $code_names);
    }

    /**
     * This method invokes the getQuestionsIn
     * With id as field
     *
     * @param $ids
     * @return mixed
     */
    public function getQuestionsById($ids)
    {
        return $this->getBlocksIn('id', $ids);
    }


    /**
     * This Method gets all the Questions
     *
     * @return mixed
     */
    public function getAllQuestions(){
        $questions = Question::where('active', '=', 1)
            //Where in with field and values
            //Also load the translation
                ->where('lft', '!=', 1)
            ->with('translation')
            ->orderBy('question_type')
            ->orderBy('lft')
            ->get();

        return $questions;
    }

}