Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
4
Indexable
Never
public function storePoint(Request $request){
        if($request->input('quizType') != 'videos' && Session::has($request->input('quizType')) && Session::get($request->input('quizType')==date('d-m-y'))){
            return 0;
        }

        if($request->input('quizType') == 'videos'
            && Session::has($request->input('quizType'))
            && Session::get($request->input('quizType')==date('d-m-y'))
            && Session::get($request->input('videos_count'))>8)
        {
            return 0;
        }

        if ($request->point > 50) {
            return 0;
        }

        $input = $request->except('quizType');
        if($request->input('quizType')=='recycle-right'){
            $input['quizRecycleRightPopAnswerDtoList'] = $request->input('quiz');
        }
        if($request->input('quizType')=='swipe-right'){
            $input['quizSwipeRightAnswerDtoList'] = $request->input('quiz');
        }

        $input['token'] = ChCrytpo::encrypt(time().$this->generateRandomString());

        $response = Common::execution('public/rsr_point/save', $input, "POST");
        if($response && isset($response->point)){
            Session::put($request->input('quizType'),date('d-m-y'));
            if($request->input('quizType') == 'videos'){
                $counter = 0;
                if(Session::has($request->input('videos_count'))){
                    $counter = Session::get($request->input('videos_count'));
                }
                $counter++;
                Session::put($request->input('videos_count'),$counter);
            }
            return $response->point;
        }
        return 0;
    }