Laravel: - 在控制器中调用函数来查看

I am new to Laravel and I am not too sure how to use it. I have a ProfileController.php where I have all the codes and I added one more piece of code to fetch the record. Now I want this record to be displayed on the Profile.blade.php inside a particular and I am not able to figure it out. Need some guidelines on how to do this. Please find my code bellow:-

ProfileController.php

    public function showTimings() {

        $con = mysql_connect('localhost','****','****');
                mysql_select_db('lblue_db',$con);

        if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
  $colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_SEO, $SEO);
$query_DetailRS1 = sprintf("SELECT business.id , business.created_at , business.updated_at , business.deleted_at , business.BUSINESS_NAME ,address.PHONE_FIXED,  address.STREET_NO , address.STREET_NAME, suburb.NAME as 'Suburb', address.POSTCODE  ,  address.PHONE_MOBILE, business.EMAIL , business.ACTIVE , business.WEBURL , business.FACEBOOK_URL , business.GOOGLEPLUS_URL , business.TWITTER_URL , business.YOUTUBE_URL , business.AD_SIZE , business.BOLD_LISTING , business.START_DATE , business.category_id  , category.NAME , business.region , business.FILE_LOCATION , business.CLIENT_ID , business.OFFER_TEXT , business.CONTRACT_ID, SEO_KeywordsDesc.businessID, SEO_KeywordsDesc.keywords, SEO_KeywordsDesc.desc, SEO_KeywordsDesc.monO, SEO_KeywordsDesc.tueO, SEO_KeywordsDesc.wedO, SEO_KeywordsDesc.thurO, SEO_KeywordsDesc.friO, SEO_KeywordsDesc.satO, SEO_KeywordsDesc.sunO, SEO_KeywordsDesc.monC, SEO_KeywordsDesc.tueC, SEO_KeywordsDesc.wedC, SEO_KeywordsDesc.thurC, SEO_KeywordsDesc.friC, SEO_KeywordsDesc.satC, SEO_KeywordsDesc.sunC, SEO_KeywordsDesc.phO, SEO_KeywordsDesc.phC, SEO_KeywordsDesc.pubClosed, SEO_KeywordsDesc.alwaysOpen, seo_keywordsdesc.keywords    ,seo_keywordsdesc.desc FROM business LEFT JOIN category ON business.category_id = category.id Left JOIN address ON business.id= address.business_id Left JOIN SEO_KeywordsDesc ON business.id= SEO_KeywordsDesc.businessID Left JOIN suburb ON  address.SUBURB_ID = suburb.id WHERE business.id = %s", GetSQLValueString($colname_DetailRS1, "int"));
$DetailRS1 = mysql_query($query_DetailRS1, $SEO) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
$count = mysql_num_rows($DetailRS1);
if($count == 0){
    $output = 'The Store is open 24 hours';
}else{

        $id = $row_DetailRS1['id'];
        $businessName = $row_DetailRS1['BUSINESS_NAME'];
        $fixedPhone = $row_DetailRS1['PHONE_FIXED'];
        $fixedMobile = $row_DetailRS1['PHONE_MOBILE'];
        $active = $row_DetailRS1['ACTIVE']; ;

        $adSize = $row_DetailRS1['AD_SIZE']; 

        $categoryName =  $row_DetailRS1['NAME'];
        $region = $row_DetailRS1['region']; 
        $streetNo = $row_DetailRS1['STREET_NO'];
        $streetName = $row_DetailRS1['STREET_NAME'];
        $suburb = $row_DetailRS1['Suburb'];
        $postcode = $row_DetailRS1['POSTCODE'];
        $clientID = $row_DetailRS1['CLIENT_ID'] ;

        $contractID = $row_DetailRS1['CONTRACT_ID'] ;

            $keywords = $row_DetailRS1['keywords'];
            $description = $row_DetailRS1['desc'] ;
            $mon  = $row_DetailRS1['Monday'] ;
            $tue  =  $row_DetailRS1['Tuesday'] ;
            $wed  = $row_DetailRS1['Wednesday'] ;
            $thur  = $row_DetailRS1['Thursday'] ;
            $fri  = $row_DetailRS1['Friday'] ;
            $sat  = $row_DetailRS1['Saturday'] ;
            $sun  = $row_DetailRS1['Sunday'] ;
            $pubhol  = $row_DetailRS1['Public Holiday'] ;
            $alwaysopen  = $row_DetailRS1['Always Open'] ;





            $lid .= $name . "Business ID";

            $lBUSINESS_NAME .= $name .  "Business Name";
            $lfixedPhone .= $name . "Fixed Number";
            $lmobilePhone .= $name .    "Mobile Number";
            $lACTIVE .= $name . "   Active";
            $lAD_SIZE .= $name .    "   AD Size";

            $lNAME .= $name .   "   Category Name";
            $lregion .= $name . "   Region";

            $lCLIENT_ID .= $name .  "Client ID";

            $lCONTRACT_ID .= $name .    "Contract ID";


            $keywords .= $name .    "Keywords: ";
            $description .= $name . "Description: ";
            $lCONTRACT_ID .= $name .    "Contract ID";
            $mon .= $name . "Monday";
            $tue .= $name . "Tuesday";
            $wed .= $name . "Wednesday";
            $thur .= $name .    "Thursday";
            $fri .= $name . "Friday";
            $sat .= $name . "Saturday";
            $sun .= $name . "Sunday";
            $pubhol .= $name .  "Public Holiday";
            $alwaysopen .= $name .  "Always Open";
        }


           date_default_timezone_set('Australia/Melbourne');
  $datetime = new \DateTime();

  $listItem = array('<li class="active">', '</li>');

 $curDay = date('l');

  $status = array( "Now Open" ,"Closed",  "Opening Soon",  "Closing Soon", "Open 24 hours", "  ");

  $times = $times = array(
    1 => array('day' => 'Monday', 'open' => date( $row_DetailRS1['monO'] ), 'close' => date( $row_DetailRS1['monC'] )),
    2 => array('day' => 'Tuesday', 'open' => date( $row_DetailRS1['tueO'] ), 'close' => date( $row_DetailRS1['tueC'] )),
    3 => array('day' => 'Wednesday', 'open' => date( $row_DetailRS1['wedO'] ), 'close' => date( $row_DetailRS1['wedC']) ),
    4 => array('day' => 'Thursday', 'open' => date( $row_DetailRS1['thurO'] ), 'close' => date( $row_DetailRS1['thurC']) ),
    5 => array('day' => 'Friday', 'open' => date( $row_DetailRS1['friO'] ), 'close' => date( $row_DetailRS1['friC'] )),
    6 => array('day' => 'Saturday', 'open' => date( $row_DetailRS1['satO'] ), 'close' => date( $row_DetailRS1['satC']) ),
    7 => array('day' => 'Sunday', 'open' => date( $row_DetailRS1['sunO'] ), 'close' => date( $row_DetailRS1['sunC'] )) );



  $html .= "  <a href=''>"; echo $curDay; $html .="</a>

               <table class='table table-striped'  border='0' align='center' cellpadding='10' cellspacing='20'>
               <tr>
                 <td>Days</td>
                 <td><span class='white-text' style='margin-right: 3em;'></td> 
                 <td>Business Hours</td> 
                 <td><span class='white-text' style='margin-right: 3em;'></td>
                 <td>Hours</td>
                </tr>";
  $i = 1;



$cd = $datetime->format('N'); 

$timenow =     date("H:i:s", time());


// Create an array of day numbers that start with current day and loops around
$day_order = array_merge(range($cd, 7), range(1, $cd-1));



 foreach ($day_order as $daynum): {
    $oc = $times[$daynum];
    $openingTime = $oc['open'];
    $closingTime = $oc['close'];
    $openingSoon = date('H:i:sA', strtotime($openingTime)-3600);
    $closingSoon = date('H:i:sA', strtotime($closingTime)-3600);
    if ($cd == $daynum) {
        if ($openingTime == ' ' && $closingTime == ' ') {
            $s = $status[4];
        }
        elseif ($timenow < $openingSoon || $timenow > $closingTime ) {
            $s = $status[1];
        }
        elseif  ($timenow > $openingSoon && $timenow < $openingTime ) {
            $s = $status[2];
        }
        elseif  ($timenow > $closingSoon && $timenow < $closingTime ) {
            $s = $status[3];
        } else {
            $s = $status[0];
        }
    } else {
        $s = " ";
    }

    $html .= "<tr>";
    $html .= "<td>". $oc['day']."</td>";
    $html .= "<td>  <span class='white-text' style='margin-right: 3em;'> </td>";
    $html .= "<td>".$openingTime." to ".$closingTime."</td>";
    $html .= "<td>  <span class='white-text' style='margin-right: 3em;'> </td>";
    $html .= "<td>".$s."</td>";
    $html .= "</tr>";

}
      $datetime->add(new \DateInterval('P1D'));








  endforeach;
  $html .= "</table>";
  echo $html;


    }

and my Profile.blade.php

<div>
  // I want my function showTimings to be displayed here
</div>

From your controller you can load your view using return view('Profile');

If you want to include data that you can access, like HTML, you can compact() the data or chain a function with() to the view method.

Option 1:

return view('profile', compact('data');

return view('profile', compact('data', 'data2', 'data3');

Option 2:

return view('profile')->with('data', $data);

return view('profile')->with(['data' => $data, 'data2' => $data2]);

Note that Laravel will automatically assume the file is postfixed with .blade.php

In both examples, you will have access to the $data variable inside your view.


But I need to say, your PHP code isn't how you would do it at all in Laravel. But it would be way too troublesome to teach you Laravel here, so I'll leave you with this link that will teach you everything you need to get started with Laravel.

https://laracasts.com/series/laravel-5-from-scratch