Q: Post with xml file in laravel I am using method post to create new data in xml file but The function c_element cannot be used in the function store
$DeTai = c_element('DeTai', $root);

This is my current code: 
public function c_element($e_name, $parent)
{
    global $xml;
    $node = $xml->createElement($e_name);
    $parent->appendChild($node);
    return $node;
}
public function c_value($value, $parent)
{
    global $xml;
    $value = $xml->createTextNode($value);
    $parent->appendChild($value);
    return $value;
}
public function store(Request $request)
{
    $xml = new DOMDocument("1.0","UTF-8");
    $xml->load('../xml/QuanLyDoAnTotNghiep.xml');

    if ($request->isMethod('post')) 
    {
        $madt= $request->madt;
        $noidungdetai = $request->noidungdetai;
        $root=$xml->getElementsByTagName("QuanLyDoAnTotNghiep")->item(0);
            $DeTai = c_element("DeTai", $root); //error in here

            $s_madt = c_element('MaDT', $DeTai);
            c_value("$madt", $s_madt);
            $s_noidungdetai = c_element('NoiDungDeTai', $DeTai);
            c_value("$noidungdetai", $s_noidungdetai);

            $xml->formatOutput=true;
            $xml->save('../xml/QuanLyDoAnTotNghiep.xml');
            echo "Thêm mới thành công!!!";
    }   
}


A: use this keyword to call one method in different method of same class
$DeTai = $this->c_element('DeTai', $root);

to know more about it please visit this
Thanks..
