$diamonds = DB::connection('pgsql')->select("select * from diamonds limit 50"); //gets diamonds
$dia = DB::connection('pgsql')->select("select dia_val || dia_type as diacol from diamonds limit 50");//returns green or red in a new column diacol
$newdiamonds = array();
foreach($dia as $r){
$singlediamond=$r->diacol;
$newdiamonds[]=$this->get_diamond_status($singlediamond); //looping through and getting whether it is emerald or ruby in array
}
function get_diamond_status(mydiamond){
if(mydiamond=='green'){
return 'emerald'
}
if(mydiamond=='red'){
return 'ruby'
}
}
return view('/diamonds')->with('diamonds',$diamonds)->with('newdiamonds',$newdiamonds);
我想要一种方法,可以将一个变量发送到包含所有数据或所有列的视图