<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\StudyMeterials;
use DB;
use Log;

class StudyMeterialsController extends Controller {

    public function lessons($type) {
        try {
            if ($type == 0) {
                $lessons = StudyMeterials::where('subject','Mathematics')->get();
            }else{
                $lessons = StudyMeterials::where('subject','Science')->get();
            }
            
            return response()->json([ 'lessons' => $lessons], 200);
        } catch ( \Exception $e ) {
            Log::error( $e );
            return response()->json([ 'message' => $e->getmessage()], 500 );
        }
    }
}
