<file_sep><?php
include_once '../DB/DBConnect.php';
include_once '../DB/StudentDB.php';
include_once '../Student.php';

$students = new StudentDB();
$allStudent = $students->getAll();

?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<table border = 4px; cellspacing="0" cellpadding="5">
    <tr>
        <td>
            STT
        </td>
        <td>
            Tên
        </td>
        <td>
            Mật khẩu
        </td>
        <td>
            Địa chỉ email
        </td>
    </tr>
    <?php foreach ($allStudent as $key=>$students): ?>
        <tr>
            <td>
                <?php echo ++$key?>
            </td>
            <td>
                <?php echo $students->getName()?>
            </td>
            <td>
                <?php echo $students->getPassword()?>
            </td>
            <td>
                <?php echo $students->getEmail()?>
            </td>
            <td>
                <a href="delete.php?id=<?php echo $students->getId(); ?>">Delete</a>
            </td>
            <td>
                <a href="update.php?id=<?php echo $students->getId(); ?>">Update</a>
            </td>
        </tr>
    <?php endforeach; ?>
</table>

</body>
</html>
<file_sep><?php


namespace App\Http\Repository\Eloquent;


use App\Customer;
use App\Http\Repository\contracts\RepositoryInterface;

class CustomerRepositoryEloquent implements RepositoryInterface
{

    public function getAll()
    {
        return Customer::paginate(5);
    }

    public function store($customer)
    {
        $customer->save();
    }

    public function findByID($id)
    {
        return Customer::FindOrFail($id);
    }

    public function update($customer)
    {
        $customer->save();
    }

    public function delete($customer)
    {
        $customer->delete();
    }
}
<file_sep><?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use phpDocumentor\Reflection\Types\This;

class City extends Model
{
    /**
     * @var array|string|null
     */

    public function customers()
    {
        return $this->hasMany('App\Customer');
    }

}


<file_sep><?php
include_once '../DBconnect.php';
include_once '../Student.php';
include_once '../DBstudent.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!empty($_POST['name']) && !empty($_POST['email'])) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $student = new Student($name, $email);
        $studentDB = new DBstudent();
        $studentDB->create($student);
        header('location: list.php', true);
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Add new student</title>
</head>
<body>
<h2>Add new student</h2>
<div class="table">
    <form method="post" action="">
        <table>
            <tr>
                <td>Name</td>
                <td><input type="text" name="name" size="20"></td>
            </tr>
            <tr>
                <td>Email</td>
                <td><input type="text" name="email" size="20"></td>
            </tr>
            <tr>
            <tr>
                <td></td>
                <td>
                    <button type="submit">Add</button>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
<file_sep><?php
include 'QuadraticEquation.php';
$mmm= new QuadraticEquation(2,6,4);
echo $mmm->getDiscriminant();
echo a;<file_sep><?php


namespace App\Http\Service;


use App\Http\Repository\NoteRepository;

class NoteService
{
    protected $noteRepository;
    public function __construct(NoteRepository $noteRepository)
    {
        $this->noteRepository = $noteRepository;
    }

    public function getAll()
    {
        return $this->noteRepository->getAll();
    }


}
<file_sep><?php

use Illuminate\Database\Seeder;

class student_data extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        for ($i = 1; $i <= 10; $i++) {
            DB::table('table_student')->insert([
                'name' => str_random(10),
                'age' => mt_rand(10,80)
            ]);
        }
    }
}
<file_sep><?php
include_once '../DB/DBConnect.php';
include_once '../Student.php';
include_once '../DB/StudentDB.php';

$id = $_GET['id'];
$studentDB = new StudentDB();
$studentDB->delete($id);
header('location: ../index.php', true);
<file_sep><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
    <input type="text" name="money" placeholder="Money First"/><br>
    <input type="text" name="month" placeholder="Month"/><br>
    <input type="text" name="interestRate" placeholder="Interest rate"/>%<br>
    <input type = "submit" id = "submit" value = "Calculator"/>
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $money = $_POST["money"];
    $month = $_POST["month"];
    $rate = $_POST["interestRate"];
    $calculator = $money + ($money * $month * $rate/100);
    echo $calculator;
}
?>
</body>
</html><file_sep><?php
include_once 'Circle.php';

class Cylinder extends Circle
{
    public $height;

    public function __construct($radius, $color, $height)
    {
        parent::__construct($radius, $color);
        $this->height = $height;
    }

    public function getHeight()
    {
        return $this->height;
    }

    public function setHeight($height)
    {
        $this->height = $height;
    }

    public function calculatorVolume()
    {
        return parent::calculatorArea() * $this->height;
    }

    public function toString()
    {
        return 'Color Cylinder: '.$this->getColor().'<br>'.'Height Cylinder: '.$this->getHeight().'<br>'.'Volume Cylinder: '.$this->calculatorVolume();
    }
}
<file_sep><?php
include_once 'DB/DBConnect.php';
include_once 'DB/StudentDB.php';
include_once 'Student.php';
$students = new StudentDB();
$allStudent = $students->getAll();;
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
<a  href="CRUD/create.php"><button>Create</button></a>

<table border = 4px; cellspacing="0" cellpadding="5">
    <tr>
        <td>
            STT
        </td>
        <td>
            Tên
        </td>
    </tr>
    <?php foreach ($allStudent as $key=>$students): ?>
    <tr>
        <td>
            <?php echo ++$key?>
        </td>
        <td>
            <?php echo $students->getName()?>
        </td>
        <td>
            <a href="CRUD/delete.php?id=<?php echo $students->getId(); ?>">Delete</a>
        </td>
        <td>
            <a href="CRUD/update.php?id=<?php echo $students->getId(); ?>">Update</a>
        </td>
    </tr>
    <?php endforeach; ?>
</table>

</body>
</html>

<file_sep><?php

namespace App\Http\Controllers;

use App\Employee;
use App\Http\Service\EmployeeService;
use Illuminate\Http\Request;

class EmployeeController extends Controller
{
    protected $employeeService;
    public function __construct(EmployeeService $employeeService)
    {
        $this->employeeService = $employeeService;
    }

    public function index()
    {
        $employees = $this->employeeService->getAll();
        return view('employees.list', compact('employees'));
    }

    public function create()
    {
        return view('employees.create');
    }

    public function store(Request $request)
    {
        $employee = new Employee();
//        $employee->manhanvien = $request->input('manhanvien');
        $employee->nhomnhanvien = $request->input('nhomnhanvien');
        $employee->hoten = $request->input('hoten');
        $employee->gioitinh = $request->input('gioitinh');
        $employee->sodienthoai = $request->input('sodienthoai');
        $employee->socmnd = $request->input('socmnd');
        $employee->ngaysinh = $request->input('ngaysinh');
        $employee->email = $request->input('email');
        $employee->diachi = $request->input('diachi');
        $employee->save();
        return redirect()->route('employees.index');
    }

    public function edit($id)
    {
        $employee = Employee::findOrFail($id);
        return view('employees.edit', compact('employee'));
    }

    public function update(Request $request, $id)
    {
        $employee = Employee::findOrFail($id);
        $employee->nhomnhanvien = $request->input('nhomnhanvien');
        $employee->hoten = $request->input('hoten');
        $employee->gioitinh = $request->input('gioitinh');
        $employee->sodienthoai = $request->input('sodienthoai');
        $employee->socmnd = $request->input('socmnd');
        $employee->ngaysinh = $request->input('ngaysinh');
        $employee->email = $request->input('email');
        $employee->diachi = $request->input('diachi');
        $employee->save();

        return redirect()->route('employees.index');
    }

    public function destroy($id)
    {
        $employee = Employee::findOrFail($id);
        $employee->delete();
        return redirect()->route('employees.index');
    }

    public function search(Request $request)
    {
        $keyword = $request->input('keyword');
        if (!$keyword) {
            return redirect()->route('employees.index');
        }
        $employees = Employee::where('name', 'LIKE', '%' . $keyword . '%')->paginate(5);
        return view('employees.list', compact('employees'));
    }
}
<file_sep><!DOCTYPE html>
<html>
<head>
<title>Free HTML5 CSS3 Metro Weather Widget | Designmaz</title>
<!-- For-Mobile-Apps -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //For-Mobile-Apps -->
<!-- Style -->
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
    <!-- Style -->
    <!-- JavaScript -->
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <!-- Javascript -->

    <script>
    function startTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById('txt').innerHTML =
            h + ":" + m + ":" + s;
        var t = setTimeout(startTime, 500);
    }
function checkTime(i) {
    if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
    return i;
}
</script>
<!--Google Analytics Designmaz-->
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-35751449-15', 'auto');ga('send', 'pageview');</script>
</head>
</head>
<body onload="startTime()">

    <h1>HTML5 CSS3 Metro Weather Widget</h1>

<div class="content">

    <div class="place">

    <div id="txt"></div>

    <div class="dmy">
    <script type="text/javascript">
var mydate=new Date()
var year=mydate.getYear()
if(year<1000)
    year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if(daym<10)
    daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"")
</script>
</div>

<div class="city">
    <p>Budapest, Hungary</p>
</div>

</div>

<div class="temp">

    <div id="dd1" class="wrapper-dropdown-3" tabindex="1">

    <span>
    <img src="images/nav.png" alt=""/>
    </span>

    <ul class="dropdown">

    <li><a href="#">TODAY</a></li>
<li><a href="#">FORECAST</a></li>
<li><a href="#">CITIES</a></li>
<li><a href="#">NATIONAL</a></li>
<li><a href="#">WORLD</a></li>
<li><a href="#">SETTINGS</a></li>

</ul>

<script type="text/javascript">

    function DropDown(el) {
        this.dd = el;
        this.initEvents();
    }
DropDown.prototype = {
    initEvents : function() {
        var obj = this;

        obj.dd.on('click', function(event){
            $(this).toggleClass('active');
            event.stopPropagation();
        });
    }
}
$(function() {
    var dd = new DropDown( $('#dd1') );
    $(document).click(function() {
        // all dropdowns
        $('.wrapper-dropdown-3').removeClass('active');
    });
});

</script>

</div>

<p>20° C</p>

<div class="day">

    <div class="sat">
    <h3>Sat</h3>
    <p>19°C↓  22°C↑</p>
</div>

<div class="sund">
    <h3>Sun</h3>
    <p>17°C↓ 20°C↑</p>
</div>

<div class="mon">
    <h3>Mon</h3>
    <p>15°C↓ 18°C↑</p>
</div>

<div class="clear"></div>

    </div>

    </div>

    <div class="clear"></div>

    </div>

    <div class="footer">
    <p>Copyright &copy; 2015 Metro Weather. All Rights Reserved | HTML Template by <a href="https://www.designmaz.net">Designmaz</a></p>
</div>
</body>
</html>
<file_sep><?php
include_once ('Rectangle.php');
include_once 'Resizeable.php';
class Square extends Rectangle implements Resizeable
{
    public function __construct($name, $width)
    {
        parent::__construct($name, $width, $width, $width);
    }
    public function resize($doublePercent)
    {
        $this->width = $this->width * $doublePercent;
    }
}<file_sep><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<form name = 'QuadraticEquation' method="post">
    <h3>ax^2 + bx + c = 0</h3>
    <input type="number" name = 'inputA' placeholder="Input a">
    <input type="number" name = 'inputB' placeholder="Input b">
    <input type="number" name = 'inputC' placeholder="Input c">
    <input type="submit" id="submit" value="Result"/>

</form>

<body>
<?php
include 'QuadraticEquation.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    $a = $_POST['inputA'];
    $b = $_POST['inputB'];
    $c = $_POST['inputC'];
    $x1x2 = -$b/(2*$a);

    $quadraticEquation = new QuadraticEquation($a,$b,$c);
    $delta = $quadraticEquation->getDiscriminant();
    if ($delta > 0) {
        echo 'x1 = '.$quadraticEquation->getRoot1().' and '.'x2 = '.$quadraticEquation->getRoot2();
    } else if ($delta = 0){
        echo 'x1 = x2 = '.$x1x2;
    } else{
        echo 'The equation has no roots';
    }
}

?>
</body>
</html><file_sep><?php
class Student{
    public $id;
    public $name;
    public function __construct($id, $name)
    {
        $this->id=$id;
        $this->name=$name;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }
}<file_sep><?php


namespace App\Http\Service;


use App\Http\Repository\Note_typeRepository;

class Note_typeService
{
    protected $note_typeRepository;
    public function __construct(Note_typeRepository $note_typeRepository)
    {
        $this->note_typeRepository = $note_typeRepository;
    }

    public function getAll()
    {
        return $this->note_typeRepository->getAll();

    }
}
<file_sep><?php 
namespace App\Http\Repository;


interface Repository
{
	public function getAll();
	public function findByID($id);
	public function create($data);
	public function update($data, $object);
	public function destroy($object);
}

 ?><file_sep><?php
class Student{
    public $id;
    public $username;
    public $password;
    public $email;
    public function __construct($id, $username, $password, $email)
    {
        $this->id=$id;
        $this->username=$username;
        $this->password=$<PASSWORD>;
        $this->email=$email;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->username;
    }
    public function getPassword(){
        return $this-><PASSWORD>;
    }
    public function getEmail(){
        return $this->email;
    }
}<file_sep><?php
include_once 'DBConnect.php';
include_once 'DBStudent.php';

$student = new DBStudent();
print_r($student->getAll());<file_sep><?php

namespace App\Providers;

use App\Http\Repository\contracts\RepositoryInterface;
use App\Http\Repository\Eloquent\CustomerRepositoryEloquent;
use App\Http\Service\CustomerServiceInterface;
use App\Http\Service\Impl\CustomerService;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(CustomerServiceInterface::class,
            CustomerService::class
            );
        $this->app->singleton(RepositoryInterface::class,
            CustomerRepositoryEloquent::class
            );
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}
<file_sep><?php
include_once '../DBconnect.php';
include_once '../Student.php';
include_once '../DBstudent.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    if (!empty($_POST['name']) && !empty($_POST['email'])) {
        if (!empty($_GET['id'])) {
            $id = $_GET['id'];
            $name = $_POST['name'];
            $email = $_POST['email'];
            $studentDB = new DBstudent();
            $studentDB->update($id, $name, $email);
        }
    }
    header('location: list.php', true);
} else {
    if (!empty($_GET['id'])) {
        $id = $_GET['id'];
        $studentDB = new DBstudent();
        $student = $studentDB->finById($id);
        if (is_string($student)) {
            echo $student . '<br>';
            echo '<a href="list.php">Trở về</a>';
            die();
        }
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Update info</title>
</head>
<body>
<h2>Updata infomation</h2>
<div class="table">
    <form method="post" action="">
        <table>
            <tr>
                <td>ID</td>
                <td>
                    <?php if (isset($_GET['id'])) {
                        $id = $_GET['id'];
                        echo $id;
                    } ?>
                </td>
            </tr>
            <tr>
                <td>Name</td>
                <td><input type="text" name="name" size="20" value="<?php echo $student->getName(); ?>"></td>
            </tr>
            <tr>
                <td>Email</td>
                <td><input type="text" name="email" size="20" value="<?php echo $student->getEmail(); ?>"></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <button type="submit">Update</button>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
<file_sep><?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use phpDocumentor\Reflection\Types\This;

class Customer extends Model
{
    protected $table = 'customer';

    public static function where(string $string, string $string1, string $string2)
    {
    }

    public function city(){
        return $this->belongsTo('App\City');
    }

}

<file_sep><?php


namespace App\Http\Service;


interface CustomerServiceInterface
{
    public function getAll();
    public function store($request);
    public function update($request, $id);
    public function delete($id);
}
<file_sep><?php

namespace App\Http\Controllers;


use App\Customer;
use App\Http\Service\Impl\CustomerService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use http\Env\Response;

class CustomerController extends Controller
{
    Protected $CustomerService;

    public function __construct(CustomerService $CustomerService)
    {
        $this->CustomerService = $CustomerService;
    }

    public function index()
    {
        $customers = $this->CustomerService->getAll();
        return view('customers.list', compact('customers'));
    }

    public function create()
    {
        return view('customers.create');
    }

    public function store(Request $request)
    {

        $this->CustomerService->store($request);
        Session::flash('success', 'Tạo mới khách hàng thành công');
        return redirect()->route('customers.index');
    }

    public function edit($id)
    {
        $customer = $this->CustomerService->findByID($id);
        return view('customers.edit', compact('customer'));
    }

    public function update(Request $request, $id)
    {
        $this->CustomerService->update($request, $id);
        Session::flash('success', 'Cập nhật khách hàng thành công');
        return redirect()->route('customers.index');
    }

    public function destroy($id)
    {
        $this->CustomerService->delete($id);
        Session::flash('success', 'Xóa khách hàng thành công');
        return redirect()->route('customers.index');
    }
}
<file_sep><?php


class DBConnect
{
    public $username ;
    public $password;
    public $dsn;
    public function __construct()
    {
        $this->username = 'root';
        $this->password = '<PASSWORD>';
        $this->dsn = "mysql:host=localhost;dbname=students_database";
    }

    public function  connect (){
        $conn = null;
        try{
            $conn = new PDO($this->dsn, $this->username, $this->password);
        }catch (PDOException $exception){
            return $exception ->getMessage();
        }
        return $conn;
    }
}<file_sep><?php

namespace App\Http\Controllers;

use App\student_model;
//use Illuminate\Http\Request;

class student_controller extends Controller
{
    public function all(){
        $student = student_model::all();
        return view('list', compact(['student']));
    }
}
<file_sep><?php
include 'MoveablePoint.php';
include  'Point.php';
$point = new Point(5,10);
$moveablepoint = new MoveablePoint(10,10,5,5);
//var_dump($point->getXY());
//echo $moveablepoint->toString();
//echo $point->toString();<file_sep><?php
include_once '../DBconnect.php';
include_once '../Student.php';
include_once '../DBstudent.php';

if ($_SERVER["REQUEST_METHOD"] == "GET") {
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
        $studentDB = new DBstudent();
        $studentDB->del($id);
    }
    header('location: list.php', true);
}
?><file_sep><?php

namespace App\Http\Controllers;

use GuzzleHttp\Client;
use Illuminate\Http\Request;

class weatherController extends Controller
{
    public function index ()
    {
        $cityID = 1581130;
        $cityName = '<NAME>i';
        $cityJson = file_get_contents('cityvn.json');
        $cities = (object)json_decode($cityJson);

        $client = new Client();
        $response = $client->request('GET', "api.openweathermap.org/data/2.5/weather?id=". $cityID ."&appid=".env("WEATHER_KEY"));
        $dataJson = $response->getBody();
        $data = json_decode($dataJson);
        $main = $data->main;
//        var_dump($main);
        return view('index', compact('main', 'cities', 'cityName'));
    }

    public function search(Request $request){
        $cityJson = file_get_contents('cityvn.json');
        $cities = (object)json_decode($cityJson);
        $cityID = $request->cityID;
        $cityName = '';
        foreach ($cities as $key => $city)
        {
            if($cityID == $city->id){
                $cityName = $city->name;
                break;
            }
        }

        $client = new Client();
        $response = $client->request('GET', "api.openweathermap.org/data/2.5/weather?id=". $cityID ."&appid=".env("WEATHER_KEY"));
        $dataJson = $response->getBody();
        $data = json_decode($dataJson);
        $main = $data->main;
        return view('index', compact('main', 'cities', 'cityName'));
    }
}
<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('welcome');
});

Route::group(['prefix'=>'notes'], function(){
    Route::get('/', 'NoteController@index')->name('notes.index');
    Route::get('/create', 'NoteController@create')->name('notes.create');
    Route::post('/create', 'NoteController@store')->name('notes.store');
    Route::get('/edit/{id}', 'NoteController@edit')->name('notes.edit');
    Route::post('/edit/{id}', 'NoteController@update')->name('notes.update');
    Route::get('/delete/{id}', 'NoteController@destroy')->name('notes.delete');
});

Route::group(['prefix'=>'notes_type'], function() {
    Route::get('/', 'Note_typeController@index')->name('notes_type.index');
    Route::get('/create', 'Note_typeController@create')->name('notes_type.create');
    Route::post('/create', 'Note_typeController@store')->name('notes_type.store');
    Route::get('/edit/{id}', 'Note_typeController@edit')->name('notes_type.edit');
    Route::post('/edit/{id}', 'Note_typeController@update')->name('notes_type.update');
    Route::get('/delete/{id}', 'Note_typeController@destroy')->name('notes_type.delete');
});
<file_sep><?php
include_once ('Circle.php');
include_once ('Cylinder.php');
include_once ('Rectangle.php');
include_once ('Square.php');
$rate = rand(1, 100);
echo $rate.'<br>';

$circle = new Circle('Circle 01', 3);
echo 'Circle area: ' . $circle->calculateArea() . '<br />';
echo 'Circle perimeter: ' . $circle->calculatePerimeter() . '<br />';
$circle->resize($rate);
echo 'Circle area 2: ' . $circle->calculateArea() . '<br />';
echo 'Circle perimeter 2: ' . $circle->calculatePerimeter() . '<br />';


$cylinder = new Cylinder('Cylinder 01', 3 , 4);
echo 'Cylinder area: ' . $cylinder->calculateArea() . '<br />';
echo 'Cylinder perimeter: ' . $cylinder->calculatePerimeter() . '<br />';
$cylinder->resize($rate);
echo 'Cylinder area 2: ' . $cylinder->calculateArea() . '<br />';
echo 'Cylinder perimeter 2: ' . $cylinder->calculatePerimeter() . '<br />';



$rectangle = new Rectangle('Rectangle 01', 3 , 4);
echo 'Rectangle area: ' . $rectangle->calculateArea() . '<br />';
echo 'Rectangle perimeter: ' . $rectangle->calculatePerimeter() . '<br />';
$rectangle->resize($rate);
echo 'Rectangle area 2: ' . $rectangle->calculateArea() . '<br />';
echo 'Rectangle perimeter 2: ' . $rectangle->calculatePerimeter() . '<br />';


$square = new Square('Square 01', 4 , 4, 4);
echo 'Rectangle area 2: ' . $square->calculateArea() . '<br />';
echo 'Rectangle perimeter 2: ' . $square->calculatePerimeter() . '<br />';
$square->resize($rate);<file_sep><?php
interface Resizeable {
    public function  resize($doublePercent);
}
<file_sep><?php

namespace App\Http\Controllers;

use App\Http\Service\NoteService;
use App\Note;
use App\Note_type;
use Illuminate\Http\Request;


class NoteController extends Controller
{
    protected $noteService;
    public function __construct(NoteService $noteService)
    {
        $this->noteService = $noteService;
    }

    public function index()
    {
        $notes = $this->noteService->getAll();
        return view('notes.list', compact('notes'));
    }
    public function create()
    {
        $notes_type = Note_type::all();
        return view('notes.create', compact('notes_type'));
    }
    public function store(Request $request)
    {
        $note = new Note();
        $note->title = $request->input('title');
        $note->content = $request->input('content');
        $note->type = $request->input('note_type');
        $note->save();
        return redirect()->route('notes.index');
    }
    public function edit($id)
    {
        $note = Note::findOrFail($id);
        $notes_type = Note_type::all();
        return view('notes.edit', compact('note', 'notes_type'));
    }

    public function update(Request $request, $id)
    {
        $note = Note::findOrFail($id);
        $note->title = $request->input('title');
        $note->content = $request->input('content');
        $note->type = $request->input('note_type');
        $note->save();

        return redirect()->route('notes.index');
    }
    public function destroy($id)
    {
        $note = Note::findOrFail($id);
        $note->delete();
        return redirect()->route('notes.index');
    }
}
<file_sep><?php
include_once '../DBconnect.php';
include_once '../Student.php';
include_once '../DBstudent.php';

$studentDB = new DBstudent();
$students = $studentDB->getAll();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>List Student</title>
</head>
<body>
<table border="1" cellspacing="0">
    <tr>
        <th>Stt</th>
        <th>Name</th>
        <th>Email</th>
        <th></th>
    </tr>
    <?php foreach ($students as $key=>$student): ?>
        <tr>
            <td><?php echo ++$key; ?></td>
            <td><?php echo $student->getName(); ?></td>
            <td><?php echo $student->getEmail(); ?></td>
            <td>
                <span><a href="update.php?id=<?php echo $student->getId(); ?>">Update</a></span>
                <span><a href="del.php?id=<?php echo $student->getId(); ?>">Delete</a></span>
            </td>
        </tr>
    <?php endforeach; ?>
</table>
<a href="create.php" type="button">Add new student</a>
</body>
</html>
<file_sep><?php

namespace App\Http\Controllers;

use App\Http\Service\Note_typeService;
use App\Note_type;
use Illuminate\Http\Request;


class Note_typeController extends Controller
{
    protected $note_typeService;
    public function __construct(Note_typeService $note_typeService)
    {
        $this->note_typeService = $note_typeService;
    }

    public function index()
    {
        $notes_type = $this->note_typeService->getAll();
//        dd($notes_type);
        return view('notes_type.list', compact('notes_type'));
    }

    public function create()
    {
        return view('notes_type.create');
    }

    public function store(Request $request)
    {
        $note_type = new Note_type();
        $note_type->name = $request->input('name');
        $note_type->description = $request->input('description');
        $note_type->save();
        return redirect()->route('notes_type.index');
    }

    public function edit($id)
    {
        $note_type = Note_type::findOrFail($id);
        return view('notes_type.edit', compact('note_type'));
    }

    public function update(Request $request, $id)
    {
        $note_type = Note_type::findOrFail($id);
        $note_type->name = $request->input('name');
        $note_type->description = $request->input('description');
        $note_type->save();

        return redirect()->route('notes_type.index');
    }

    public function destroy($id)
    {
        $note_type = Note_type::findOrFail($id);
        $note_type->delete();
        return redirect()->route('notes.index');

    }
}
<file_sep><?php
include 'Point2D.php';
include 'Point3D.php';
$point2D = new Point2D(4,6);
$point3D = new Point3D(3,5,7);
echo $point2D->toString()."<br>";

echo $point3D->toString();
//var_dump($point3D->toString());
<file_sep><?php


namespace App\Http\Service\Impl;


use App\Customer;
use App\Http\Repository\Eloquent\CustomerRepositoryEloquent;
use App\Http\Service\CustomerServiceInterface;

class CustomerService implements CustomerServiceInterface
{
    protected $customerRepository;
    public function __construct(CustomerRepositoryEloquent $customerRepository)
    {
        $this->customerRepository = $customerRepository;
    }


    public function getAll()
    {
        return $this->customerRepository->getAll();
    }

    public function store($request)
    {
        $customer = new Customer();
        $customer->name = $request->input('name');
        $customer->email = $request->input('email');
        $customer->dob = $request->input('dob');

        $this->customerRepository->store($customer);
    }
    public function findByID($id){
        return $this->customerRepository->findByID($id);
    }

    public function update($request, $id)
    {
        $customer = $this->customerRepository->findByID($id);
        $customer->name = $request->input('name');
        $customer->email = $request->input('email');
        $customer->dob = $request->input('dob');
    }

    public function delete($id)
    {
        $customer = $this->customerRepository->findByID($id);
        $this->customerRepository->delete($customer);
    }
}
<file_sep><?php
function find($keyword, $file){
    $characters = json_decode(file_get_contents($file), true);
    for ($i = 0; $i < count($characters); $i++) {
        if ($keyword === $characters[$i]['username']) {
            return $i;
        }
    }
}

function delete($index, $arr, $file){
    readJson($file);
    unset($arr, $index);
}

function readJson($file){
    $outputData = json_decode(file_get_contents($file), true);
    return $outputData;
}

function saveFile($user, $file){
    $data = readJson($file);
    array_push($data,$user);
    $data = json_encode($data,1);
    file_put_contents($file, $data);

}<file_sep><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
    <input type="text" name="firstNumber"/>x<br>
    <select name="action">
        <option value="+">Cong</option>
        <option value="-">Tru</option>
        <option value="*">Nhan</option>
        <option value="/">Chia</option>
    </select><br>
    <input type="text" name="secondNumber"/>y<br>
    <input type="submit" id="submit" value="Calculator"/>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $x = $_POST["firstNumber"];
    $y = $_POST["secondNumber"];
    $action = $_POST["action"];

    if ($y == 0) {
        echo "Xảy ra ngoại lệ";
    } else if ($x==0 && $y == 0) {
        echo "Xảy ra ngoại lệ";
    } else {
        switch ($action) {
            case "+":
                $result = $x + $y;
                break;
            case "-":
                $result = $x - $y;
                break;
            case "*":
                $result = $x * $y;
                break;
            case "/":
                $result = $x / $y;
                break;
        }
        echo $x . $action . $y . "=" . $result;
    }
}
?>
</body>
</html>
<file_sep><?php
include_once 'DB/DBConnect.php';
include_once 'DB/StudentDB.php';
//include_once 'Student.php';

$studentDB = new StudentDB();
//$allStudent = $students->getAll();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
//    if ($students->checkUsername($username) == 1 && $students->checkPassword($password) > 0) {
//        $obj = $students->selectUser($username);
//        foreach ($obj as $item) {
//            if ($username == $item->getName() && $password == $item->getPassword()) {
//                if ($username == 'admin') {
//                    header("location: CRUD/admin.php");
//                } else {
//                    header("location: CRUD/user.php?username=$username");
//                }
//            } else {
//                echo "username hoặc password không đúng";
//            }
//        }
//    }

    if ($studentDB->checkUsernamePassword($username, $password)) {
        if ($username == 'admin') {
            header("location: CRUD/admin.php");
        } else {
            header("location: CRUD/user.php?username=$username");
        }
    } else {
        echo "username hoặc password không đúng";
    }

}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>

<body>
<form method="post">
    <input placeholder="username" name="username"><br>
    <input placeholder="<PASSWORD>" name="password"><br>

    <button>Login</button>
    <br>
</form>
<a href="CRUD/create.php">Register</a>

</body>
</html><file_sep><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h3>Conventer number to text</h3>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
    <input type="text" name="search" placeholder="Write"/>
    <input type="submit" id="submit" value="Conventer"/>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $input = $_POST["search"];
    if ($input < 10) {
        switch ($input) {
            case 1:
                echo 'one';
                break;
            case 2:
                echo 'two';
                break;
            case 3:
                echo 'three';
                break;
            case 4:
                echo 'four';
                break;
            case 5:
                echo 'five';
                break;
            case 6:
                echo 'six';
                break;
            case 7:
                echo 'seven';
                break;
            case 8:
                echo 'eight';
                break;
            case 9:
                echo 'night';
                break;
        }
    }
}

?>

</body>
</html><file_sep><?php
function selectionSort()
{
    $arr = array();
    for ($i = 0; $i < 100000; $i++){
        array_push($arr, $i);
    }
    return $arr;
}


<file_sep><?php


namespace App\Http\Service;


use App\Http\Repository\EmployeeRepository;

class EmployeeService
{
    protected $employeeRepository;
    public function __construct(EmployeeRepository $employeeRepository)
    {
        $this->employeeRepository = $employeeRepository;
    }

    public function getAll()
    {
        return $this->employeeRepository->getAll();
    }


}
<file_sep><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
    <input type="text" name="productName"/>Product Name<br>
    <input type="text" name="listPrice"/>List Price<br>
    <input type="text" name="discount"/>Discount percent (%)<br>
    <input type = "submit" id = "submit" value = "Calculator Discount"/>
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $productName = $_POST["productName"];
    $listPrice = $_POST["listPrice"];
    $discount = $_POST["discount"];
    $calculatorDiscount = $listPrice * $discount / 100;
    $newPrice = $listPrice - $calculatorDiscount;
    echo "Product Name: ".$productName."<br>"."Price: ".$listPrice."<br>"."Discount Percent: ".$discount."<br>"."Discount Amount: "."$calculatorDiscount"."<br>"."Discount Price: ".$newPrice;
}
?>
</body>
</html><file_sep><?php
include_once 'Circle.php';
include_once 'Cylinder.php';
$circle = new Circle(5, 'blue');
echo $circle->toString().'<br>'.'<br>';
$cylinder = new Cylinder(5, 'green', 10);
echo $cylinder->toString();
<file_sep><?php
function minimum($arr)
{
    $min = $arr[0];
    for ($i = 1; $i < count($arr); $i++) {
        if ($min > $arr[$i]) {
            $index = $i;
        }
    }
    return $index;
}

$arr = [3, 4, 5, 3, 6, 1, 6];
//    minimum($arr);
echo minimum($arr);


<file_sep><?php


namespace App\Http\Repository;



use App\Note_type;

class Note_typeRepository
{
    public function getAll()
    {
        return Note_type::all();
    }
}
<file_sep><?php
//include_once '../AbstractClass/Animal.php';
//
//class Dog extends Animal{
//    public function makeSound()
//    {
//        return "Dog: woof woof";
//    }
//
//}




//include_once './AbstractClass/Animal.php';
//
//class Chicken extends Animal{
//    public function makeSound()
//    {
//        return "Chicken: cluck-cluck";
//    }
//    public function howToEat()
//    {
//        return "could be fried";
//    }
//
//}<file_sep><?php

class DBStudent
{
    public $conn;
    public function __construct()
    {
        $db = new DBconnect();
        $this->conn = $db->connect();
    }
    public function getAll()
    {
        $sql = "SELECT * FROM `Student`";
        $mysql = $this -> conn -> query($sql);

        $data = $mysql -> fetchAll();
        return $data;
    }
}
<file_sep><?php
function minimum($arr)
{
    $max = 0;
    for ($i = 0; $i < count($arr); $i++) {
        for ($j = 0; $j < count($arr[$i]); $j++) {
            if ($max < $arr[$i][$j]) {
                $max = $arr[$i][$j];
            }
        }
    }
    return $max;
}
$arr = [[3, 4, 5], [6, 7, 8]];
echo minimum($arr);


<file_sep><?php
include_once 'function.php';


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $pass = $_POST['<PASSWORD>'];
    $user = [
        'username' => $username,
        'pass' => $pass
    ];

    $file = 'data.json';

    if (!empty($username) && !empty($pass)) {
        saveFile($user, $file);

    }
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $delete = $_GET['deleteUsername'];
    $file = 'data.json';
    $arr = json_decode(file_get_contents($file), true);
    if (!empty($delete)){
        delete(find($delete, $file),$arr, $file);
    }
}<file_sep><?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class student_model extends Model
{
    protected $table ='table_student';
}
<file_sep><?php
include_once 'DBConnect.php';
include_once 'index.php';
include_once '../Student.php';
class StudentDB
{
    public $conn;

    public function __construct()
    {
        $db = new DBConnect();
        $this->conn = $db->connect();
    }

    public function getAll()
    {
        $sql = "SELECT * FROM Student";
        $mysql = $this->conn->query($sql);
        $mysql->setFetchMode(PDO::FETCH_ASSOC);
        $data = $mysql->fetchAll();
        $arr = [];
        foreach ($data as $item){
            $student = new Student($item['id'], $item['name']);
            array_push($arr, $student);
        }
        return $arr;
    }

    public function create($name)
    {
        $sql = "INSERT INTO Student(`name`) VALUES ('$name')";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
    }

    public function update($name, $id)
    {
        $sql = "UPDATE `Student` SET `name`='$name' WHERE id = '$id'";
        $mysql = $this->conn->query($sql);
    }

    public function delete($id)
    {
        $sql = "DELETE FROM `Student` WHERE id = '$id'";
        $mysql = $this->conn->query($sql);
    }


}<file_sep><?php

namespace App\Http\Controllers;


use App\City;
use App\Customer;
use App\Http\Service\Impl\CustomerService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use http\Env\Response;

class CustomerController extends Controller
{
    Protected $CustomerService;

    public function __construct(CustomerService $CustomerService)
    {
        $this->CustomerService = $CustomerService;
    }

    public function index()
    {
        $customers = $this->CustomerService->getAll();
        $cities = City::all();
        return view('customers.list', compact('customers', 'cities'));
    }

    public function create()
    {
        $cities = City::all();
        return view('customers.create', compact('cities'));
    }

    public function store(Request $request)
    {

        $customer = new Customer();
        $customer->name = $request->input('name');
        $customer->email = $request->input('email');
        $customer->dob = $request->input('dob');
        $customer->city_id = $request->input('city_id');
        $customer->save();

        return redirect()->route('customers.index');
    }

    public function edit($id)
    {
        $customer = Customer::findOrFail($id);
        $cities = City::all();

        return view('customers.edit', compact('customer', 'cities'));
    }

    public function update(Request $request, $id)
    {
        $customer = Customer::findOrFail($id);
        $customer->name = $request->input('name');
        $customer->email = $request->input('email');
        $customer->dob = $request->input('dob');
        $customer->city_id = $request->input('city_id');
        $customer->save();

        Session::flash('success', 'Cập nhật khách hàng thành công');

        return redirect()->route('customers.index');
    }

    public function destroy($id)
    {
        $this->CustomerService->delete($id);
        Session::flash('success', 'Xóa khách hàng thành công');
        return redirect()->route('customers.index');
    }

    public function filterByCity(Request $request)
    {
        $idCity = $request->input('city_id');
        $cityFilter = City::findOrFail($idCity);
        $customers = Customer::where('city_id', $cityFilter->id)->get();
        $totalCustomerFilter = count($customers);
        $cities = City::all();
        return view('customers.list', compact('customers', 'cities', 'totalCustomerFilter', 'cityFilter'));
    }

    public function search(Request $request)
    {
//        $keyword = $request->input('keyword');
//        if (!$keyword) {
//            return redirect()->route('customers.index');
//        }
//
//        $customers = Customer::where('name', 'LIKE', '%' . $keyword . '%')->paginate(5);
//        dd($customers);
//
//        $cities = City::all();
////        dd($keyword);
//        return view('customers.list', compact('customers', 'cities'));

        $keyword = $request->input('keyword');

        if (!$keyword) {

            return redirect()->route('customers.index');

        }

        $customers = Customer::where('name', 'LIKE', '%' . $keyword . '%')->paginate(5);


        $cities = City::all();

        return view('customers.list', compact('customers', 'cities'));
    }
}
<file_sep><?php


class DBconnect
{
    public $dsn;
    public $username;
    public $password;

    public function __construct()
    {
        $this->dsn = 'mysql:host=localhost;dbname=student-manager';
        $this->username = 'root';
        $this->password = '<PASSWORD>';
    }

    public function connect()
    {
        $conn = null;
        try{
            $conn = new PDO($this->dsn, $this->username, $this->password,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
        } catch (PDOException $e){
            echo $e -> getMessage();
        }
        return $conn;
    }
}
<file_sep><?php


namespace App\Http\Repository;


use App\Employee;


class EmployeeRepository
{
    public function getAll()
    {
        return Employee::all();
    }
}
<file_sep><?php

class QuadraticEquation
{
    private $a;
    private $b;
    private $c;

    public function __construct($a, $b, $c)
    {
        $this->a = $a;
        $this->b = $b;
        $this->c = $c;
    }

    public function getA()
    {
        return $this->a;
    }
    public function getB()
    {
        return $this->b;
    }

    public function getC()
    {
        return $this->c;
    }
    public function getDiscriminant(){
        return pow($this->b,2) - 4*$this->a*$this->c;
    }
    public function getRoot1(){
        return (-$this->get + pow((pow($this->b,2) - 4*$this->a*$this->c), 0.5))/(2*$this->a);
    }
    public  function getRoot2(){
        return (-$this->b - pow((pow($this->b,2) - 4*$this->a*$this->c), 0.5))/(2*$this->a);
    }

}<file_sep><?php
include_once "DBconnect.php";
include_once "Student.php";

class DBstudent
{
    public $conn;

    public function __construct()
    {
        $db = new DBconnect();
        $this->conn = $db->connect();
    }

    public function getAll()
    {
        $sql = 'SELECT * FROM students';
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $data = $stmt->fetchAll();
        $arr = [];

        foreach ($data as $item) {
            $student = new Student($item['name'], $item['email']);
            $student->id = $item['id'];
            array_push($arr, $student);
        }
        return $arr;
    }

    public function create($obj)
    {
        $name = $obj->getName();
        $email = $obj->getEmail();
        $sql = "INSERT INTO students(`name`,`email`) VALUE ('$name','$email')";
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
    }

    public function del($id)
    {
        $sql = "DELETE FROM `students` WHERE id='$id'";
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
    }

    public function update($id, $name, $email)
    {
        $sql = "UPDATE `students` SET `name`='$name',`email`='$email' WHERE id='$id'";
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
    }

    public function finById($id)
    {
        $sql = 'SELECT * FROM students where id=' . $id;
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $data = $stmt->fetch();
        if ($data) {
            $student = new Student($data['name'], $data['email']);
            $student->id = $data['id'];
            return $student;
        } else {
            return 'Người dùng không tồn tại.';
        }
    }
}



<file_sep><?php
include_once 'DBConnect.php';
include_once '../Student.php';

class StudentDB
{
    public $conn;

    public function __construct()
    {
        $db = new DBConnect();
        $this->conn = $db->connect();
    }

    public function getAll()
    {
        $sql = "SELECT * FROM Student";
        $mysql = $this->conn->query($sql);
        $mysql->setFetchMode(PDO::FETCH_ASSOC);
        $data = $mysql->fetchAll();
        $arr = [];
        foreach ($data as $item) {
            $student = new Student($item['id'], $item['username'], $item['password'], $item['email']);
            array_push($arr, $student);
        }
        return $arr;
    }

    public function create($username, $password, $email)
    {
        $sql = "INSERT INTO Student(`username`,`password`,`email`) VALUES ('$username','$password','$email')";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
    }

    public function update($username, $password, $email, $id)
    {
        $sql = "UPDATE `Student` SET `username`='$username', `password`='$<PASSWORD>', `email`='$email' WHERE id = '$id'";
        $mysql = $this->conn->query($sql);
    }

    public function delete($id)
    {
        $sql = "DELETE FROM `Student` WHERE id = '$id'";
        $mysql = $this->conn->query($sql);
    }

    public function checkUsername($username)
    {
        $sql = "SELECT * FROM Student WHERE `username`='$username'";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
        $result = $mysql->rowCount();
        return $result;
    }

    public function checkPassword($password)
    {
        $sql = "SELECT * FROM Student WHERE `password`='$password'";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
        $result = $mysql->rowCount();
        return $result;
    }

    public function checkUsernamePassword($username, $password)
    {
        $sql = "SELECT * FROM Student WHERE `username`='$username'AND `password`='$<PASSWORD>'";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
        $result = $mysql->rowCount();
        return $result;
    }

    public function checkEmail($email)
    {
        $sql = "SELECT * FROM Student WHERE `email`='$email'";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
        $result = $mysql->rowCount();
        return $result;
    }

    public function selectUser($username)
    {
        $sql = "SELECT * FROM Student WHERE `username`='$username'";
        $mysql = $this->conn->prepare($sql);
        $mysql->execute();
        $data = $mysql->fetchAll();
        $arr = [];
        foreach ($data as $item) {
            $student = new Student($item['id'], $item['username'], $item['password'], $item['email']);
            array_push($arr, $student);
        }
        return $arr;
    }

}