<file_sep><?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Employee extends Model
{
     protected $table = 'employee';
    protected $fillable = ['id','name','nric','department','temperature','quest1','quest2','quest3','quest4','quest5','quest6','quest7','quest8','quest9','quest10'];
}
<file_sep><?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVisitorTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('visitor', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('designation');
            $table->string('company');
            $table->string('visitingwho');
            $table->string('quest11');
            $table->string('quest12');
            $table->string('quest13');
            $table->string('quest14');
            $table->string('quest15');
            $table->string('quest16');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('visitor');
    }
}
<file_sep><?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEmployeeTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('employee', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('nric');
            $table->string('department');
            $table->string('temperature');
            $table->string('quest1');
            $table->string('quest2');
            $table->string('quest3');
            $table->string('quest4');
            $table->string('quest5');
            $table->string('quest6');
            $table->string('quest7');
            $table->string('quest8');
            $table->string('quest9');
            $table->string('quest10');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('employee');
    }
}
<file_sep><?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Visitor extends Model
{
     protected $table = 'visitor';
    protected $fillable = ['id','name','designation','company','visitingwho','quest1','quest2','quest3','quest4','quest5','quest6'];
}
<file_sep><?php

namespace App\Http\Controllers\TempCheck;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Temp;
use Carbon\Carbon;
use DB;

class TempCheckController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('tempcheck.create');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
         
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

     $checker = Carbon::today();


         $user =Temp::where('name',$request->name)->whereDate('created_at', $checker)->first();
         

        
            
        if(empty($user)) { 


        Temp::create([
           'name'            =>  $request->get('name'),
           'temperature'     =>  $request->get('temperature'), 
        ]);

         $checktemp = $request->temperature;
         $checkname = $request->name;

         // dd($checktemp);
       
        return redirect()->back()->with('success','Done! Your temperature has been recorded')
        ->with('checktemp',$checktemp )->with('checkname',$checkname );
       }

       else{

          return redirect()->back()->with('failed','Your temperature has been recorded for today');
       }
         
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
       
}
<file_sep><?php

namespace App\Http\Controllers\Form;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Employee;


class EmployeeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
    
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {


         $this->validate($request,[
        'name' => 'required',
        'nric' => 'required',
        'department' => 'required',
        'temperature' => 'required',
        'quest1' => 'required',
        'quest2' => 'required',
        'quest3' => 'required',
        'quest4' => 'required',
        'quest5' => 'required',
        'quest6' => 'required',
        'quest7' => 'required',
        'quest8' => 'required',
        'quest9' => 'required',
        'quest10' => 'required',
        ],

        [
        'name.required'   => 'The full name field is required',
        'nric.required'   => 'The staff NRIC field is required',
        'department.required'   => 'The department field is required.',
        'temperature.required'   => 'The temperature field is required.',
        'quest1.required' => 'Please answer questions 1',
        'quest2.required' => 'Please answer questions 2',
        'quest3.required' => 'Please answer questions 3',
        'quest4.required' => 'Please answer questions 4',
        'quest5.required' => 'Please answer questions 4.1',
        'quest6.required' => 'Please answer questions 4.2',
        'quest7.required' => 'Please answer questions 4.3',
        'quest8.required' => 'Please answer questions 4.4',
        'quest9.required' => 'Please answer questions 4.5',
        'quest10.required' =>'Please answer questions 5',
 
        ]);  


         Employee::create($request->all());
        return redirect()->back()->with('success','Thank your for your time!');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
<file_sep><?php

namespace App\Http\Controllers\Report;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Temp;
use Carbon\Carbon;
use DB;

class ReportController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
         
        $mytime = Carbon::now();

        $recordstaff  =Temp::whereDate('created_at','=',$mytime)->get();
      
        return view ('report.index', compact('recordstaff'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)

    {
           if(is_null($request->from_date))
        {
         

            $mytime = Carbon::now();

            $recordstaff  = Temp::whereDate('created_at','=',$mytime)->get();

             return view ('report.index', compact('recordstaff'));  
       

        }

          else

        {
        

            $fromdate = Carbon::parse($request->from_date);
            

            $todate = Carbon::parse($request->to_date)->addDays(1);



            $recordstaff  = Temp::whereBetween('created_at',array($fromdate, $todate))->get();
          
            // dd($recordstaff);
            return view ('report.index', compact('recordstaff','fromdate','todate'));   

            

            

        }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
<file_sep><?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('tempcheck.create');
});

Route::resource('TempCheck','TempCheck\TempCheckController');

Route::resource('Report','Report\ReportController');

Route::resource('DeclarationForm','Form\FormController');

Route::resource('Employee','Form\EmployeeController');

Route::resource('Visitor','Form\VisitorController');

Route::resource('List','Form\ListController');

Route::resource('EmployeeQuestList','Quest\EmployeeQuestController');

Route::resource('VisitoreQuestList','Quest\VisitorQuestController');

