<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Quotation;
use App\Models\Developer;
use App\Models\Team;
use App\Models\UnitManager;
use App\Models\Project;
use App\Models\Agent;
use App\Models\TestData;

use DB;
use Auth;

class TestDataController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index() {
        //$agents = Agent::where('id', '<=', 5)->get();
        $agents = DB::select( DB::raw('SELECT * FROM agents where id <= 5 ORDER BY id'));

        /*$data = [];
        foreach ($agents as $key => $value) {
            dd($value['id']);
            $data[] = array_push($data, $value['fullname']);
        }*/
        //dd($agents);

        foreach($agents as $agent) {
            $r = new TestData();
            $r->agent_id = $agent->id;
            $r->amount = 500;
            $r->save();
        }
        echo 'Saving Done.';
        //return view ('testdata.index'); //, compact('props'));
    }

}
