コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $exchange = \App\Exchange::create(['name' => 'NASDAQ']);
     $share1 = new \App\Share(['name' => 'Apple', 'symbol' => 'AAPL', 'guruwatch' => '350015372']);
     $share2 = new \App\Share(['name' => 'Google', 'symbol' => 'GOOG', 'guruwatch' => '350186927']);
     $exchange->shares()->save($share1);
     $exchange->shares()->save($share2);
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getExchangex($amount, $cur, $date)
 {
     if ($cur == 'EURO') {
         $cur = 'EUR';
     }
     $dbcur = $cur . "INR";
     //datex
     $datex = explode("-", $date);
     $datey[0] = $datex[0];
     $datey[1] = $datex[1];
     $datey[2] = $datex[2];
     $dbdate = implode("-", $datey);
     $exchange = Exchange::where("date", "=", $dbdate)->get();
     $amountx = $exchange[0]->{$dbcur} * $amount;
     return $amountx;
     //dd($exchange);
 }