public function attributes()
{
return $this->belongsToMany('App\Models\ProductAttribute', 'product_attribute', 'id', 'attribute_id');
}
Product::with(['attributes' => function ($q) use ($ar_select_properties) {
$q->whereIn('id', $ar_select_properties);
}])->get();
<?php
include "simple_html_dom.php";
function GetRWGames($rw_cat) {
$live = new simple_html_dom();
usleep(300);
$ch = curl_init("http://live.robinwidget.org/static/section" . $rw_cat . ".html");
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200 && $response !== false && !empty($response)) {
$games = array();
$live = str_get_html($response);
$counter = 0;
foreach($live->find(".lshpanel") as $game) {
$f_game = new simple_html_dom();
$f_game = str_get_html($game->outertext);
$games[$counter]['cat'] = $f_game->find(".section", 0)->plaintext;
$games[$counter]['time'] = $f_game->find(".date", 0)->plaintext;
$temp = $f_game->find(".lshevent",0)->plaintext;
$temp = explode(" - ", $temp);
$games[$counter]['team1'] = trim($temp[0]);
$games[$counter]['team2'] = trim($temp[1]);
$temp = $f_game->find("a");
$games[$counter]['links'] = "";
foreach ($temp as $a) {
$a=$a->href;
if (stristr($a, "javascript:openWindow")==true) {
$temp= strstr($a, "http");
$temp= strstr($temp, '"',1);
$games[$counter]['links'] .= $temp . ";";
} elseif(!strpos($a,"adserving")&&!strpos($a,"adsrv")&&!empty($a)) {
$games[$counter]['links'] .= $a . ";";
}
}
$counter++;
$f_game->clear();
unset($f_game);
}
return $games;
}
$live->clear();
unset($live);
}
// Load HTML from a string
$rw_cats = array(35,36,37,38,39,57,59);
foreach($rw_cats as $rw_cat){
print_r(GetRWGames($rw_cat));
}
foreach($data as $game) {
$new_live = new simple_html_dom();
$new_live->load_file($game);
$games[$counter][cat] = $new_live->find(".section",0)->plaintext;
$games[$counter][time] = $new_live->find(".date",0)->plaintext;
$temp = $new_live->find(".lshevent",0)->plaintext;
$temp = explode(" - ", $temp);
$games[$counter][team1] = trim ($temp[0]);
$games[$counter][team2] = trim ($temp[1]);
$temp = $new_live->find("a");
foreach ($temp as $a) {
$a=$a->href;
if(stristr($a, "javascript:openWindow")==true){
$temp= strstr($a, "http");
$temp= strstr($temp, '"',1);
$games[$counter][links] .= $temp . ";";}
elseif(!strpos($a,"adserving")&&!strpos($a,"adsrv")&&!empty($a))
{$games[$counter][links] .= $a . ";";}
}
$counter++;
}
return $games;