public function destroy($id, Request $request) { $set = Set::find($id); $set->delete(); $request->session()->flash('msg', 'Set deleted'); return redirect()->action('SetController@index'); }
public function postAddset(Request $request) { $this->validate($request, ['setid' => 'integer']); $setid = $request->input('setid'); $set = new Set(); if (!empty($setid)) { $set = Set::find($setid); } $set->name = $request->input('setname'); $set->drivertype = 0; if ($request->input('drivertype') == 1) { $set->drivertype = 1; } $set->datatype = $request->input('datatype'); $set->save(); $ids = explode(',', $request->input('requests')); Runner::where("setid", "=", $setid)->where("state", "=", "static")->delete(); for ($i = 1; $i < count($ids) - 1; $i++) { $runner = new Runner(); $runner->setid = $set->id; $runner->requestid = $ids[$i]; $runner->state = "static"; $runner->checkid = 1; $runner->checkstate = 0; $runner->save(); } return view("work.autotest.set.showset")->withSet($set); }
public function getSet($id) { $set = Set::find($id); $setid = $set->id; $setname = $set->name; $execnum = 1; $reqnum = Runner::where('setid', '=', $set->id)->where('state', '=', 'static')->count(); $requestids = Runner::where('setid', '=', $set->id)->where('state', '=', 'static')->get(); for ($i = 0; $i < sizeof($requestids); $i++) { $test = new AutoTestController(); $num = sizeof($test->LoadDataByID($requestids[$i]->requestid)); if ($set->drivertype == 0) { if ($set->datatype == 0) { if ($execnum > $num) { $execnum = $num; } } else { if ($set->datatype == 1) { if ($execnum < $num) { $execnum = $num; } } } } else { $execnum = $set->datatype; } } $checkid = "003"; $checkexecnum = "5"; $setMsgTmp = array('setid' => $setid, 'setname' => $setname, 'reqnum' => $reqnum, 'execnum' => $execnum, 'checkid' => $checkid, 'checkexecnum' => $checkexecnum); return Response::json($setMsgTmp); }
/** * Run the database seeds. * * @return void */ public function run() { $set = Set::create(array('name' => 'StartingBlock Madison', 'rows' => 75, 'cols' => 100, 'price' => 25, 'available' => 75 * 100)); for ($x = 1; $x <= 100; $x++) { for ($y = 1; $y <= 75; $y++) { DB::table('squares')->insert(['set_id' => $set->id, 'number' => x * y, 'status' => 'available']); } } }
private function transformSets($xml) { $sets = []; foreach ($xml as $node) { $set = new Set(); if ($node->attributes()->name) { $set->name = (string) $node->attributes()->name; } if ($node->attributes()->encore) { $set->encore = (string) $node->attributes()->encore; } $songs = $this->transformSongs($node->song); foreach ($songs as $song) { $set->songs()->associate($song); } $sets[] = $set; } return $sets; }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $set = Set::find($id); $sc = SetContent::where('set_id', $set->id)->first(); if (!$sc) { $sc = SetContent::create(array('set_id' => $set->id)); } $sc->header = $request->input('header-content'); $sc->disclaimer = $request->input('disclaimer-content'); // Todo - mobile content $sc->save(); return $sc; }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { \Stripe\Stripe::setApiKey(env('STRIPE_PRI', null)); // Create a Customer $customer = \Stripe\Customer::create(array("source" => $request->input('token_id'), "description" => $request->input('name') . ' ' . $request->input('email'))); // Charge the Customer instead of the card \Stripe\Charge::create(array("amount" => $request->input('price') * 100, "currency" => "usd", "customer" => $customer->id)); $set = Set::find(1); $data = array('set_id' => $set->id, 'customer_id' => $customer->id, 'price' => $request->input('price'), 'name' => $request->input('name'), 'email' => $request->input('email'), 'optin' => $request->input('optin')); if ($request->has('media_id')) { $data['media_id'] = $request->input('media_id'); } else { if ($request->has('color')) { $data['color'] = $request->input('color'); } } $purchase = Purchase::create($data); // Mobile doesn't have chosen array if ($request->has('mobile')) { $squares = Square::where('status', 'available')->where('set_id', $set->id)->take($request->input('blocks'))->get(); foreach ($squares as $s) { $s->class = 'taken'; $s->status = 'unavailable'; $s->save(); PurchaseSquare::create(array('purchase_id' => $purchase->id, 'square_id' => $s->id, 'set_id' => $set->id)); } } else { $squares = $request->input('chosen'); foreach ($squares as $square_id) { $s = Square::find($square_id); $s->class = 'taken'; $s->status = 'unavailable'; $s->save(); PurchaseSquare::create(array('purchase_id' => $purchase->id, 'square_id' => $s->id, 'set_id' => $set->id)); } } return $purchase; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return Set::where('id', $id)->with(['squares' => function ($q) { $q->where('class', 'invisible')->select('id', 'set_id', 'class'); }])->first(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return Set::with('rewards.media')->where('id', $id)->first(); }
/** * Update the specified resource in storage. * /api/admin/set/{id}/available * @param Request $request * @param int $id * @return Response */ public function available(Request $request, $id) { $unavailable = $request->input('chosen'); $available = $request->input('unchosen'); if (count($available) > 0) { foreach ($available as $square_id) { $s = Square::find($square_id); $s->status = 'available'; $s->save(); } } if (count($unavailable) > 0) { foreach ($unavailable as $square_id) { $s = Square::find($square_id); $s->status = 'invisible'; $s->save(); } } $set = Set::find($id); $set->available = $set->rows * $set->cols - Square::where('set_id', $id)->where('status', 'invisible')->count(); $set->save(); return $set; }
/** * Show the form for editing a minifig * @access public * @param int $id */ public function edit($id) { $minifig = Minifig::findOrFail($id); $images = $minifig->images; return view('minifig_edit')->with('sets_id', Set::orderBy('name', 'asc')->pluck('name', 'id'))->with('images', $images)->with('minifig', $minifig); }
/** * Upload the generated static image * * @return Response */ public function generate(Request $request) { if ($request->has('image')) { $set_id = 1; $base64 = substr($request->input('image'), strpos($request->input('image'), ",") + 1); $filename = round(microtime(true) * 1000) . '.jpg'; $path = 'img/sets/' . $set_id . '/'; $filelocation = public_path('/') . $path . $filename; file_put_contents($filelocation, base64_decode($base64)); $media = Media::create(array('type' => 'jpg', 'path' => $path . $filename, 'url' => asset($path . $filename))); $set = Set::find($set_id); $set->media_id = $media->id; $set->save(); return $media; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Reward::destroy($id); $set = Set::find(1); $rewards = Reward::with('media')->where('set_id', $set->id)->orderby('blocks', 'desc')->get(); return view('admin.rewards.index', ['set' => $set, 'rewards' => $rewards]); }
/** * Display the grid to generate a large image from * /admin/set/content * @return Response */ public function content() { $set = Set::with('squares.purchase.media', 'content', 'rewards')->where('id', 1)->first(); return view('admin.set.content', ['set' => $set]); }
/** * Display a listing of the resource. * * @return Response */ public function thanks($purchase_id) { $purchase = Purchase::find($purchase_id); $set = Set::with('squares.purchase.media')->where('id', 1)->first(); return view('public.thanks', ['set' => $set, 'purchase' => $purchase]); }