public function run() { DB::table('entries')->delete(); Entry::create(array('title' => 'Go skydiving', 'completed' => True)); Entry::create(array('title' => 'Finish this app', 'completed' => True)); Entry::create(array('title' => 'Run a marathon')); }
public function addEntry(CreateEntryRequest $request) { $entryId = Request::get('entryId'); $title = $request->title; $slug = strtolower($title); $slug = preg_replace('[ ]', '-', $slug); $slug = preg_replace('[^\\w-]', '', $slug); $cover = $request->cover; $rawContent = $request->rawContent; $parsedContent = Markdown::parse($rawContent); $isHidden = $request->isHidden == null ? false : true; if ($entryId != null) { $entry = Entry::find($entryId); $entry->title = $title; $entry->slug = $slug; $entry->cover = $cover; $entry->content = $parsedContent; $entry->rawContent = $rawContent; $entry->isHidden = $isHidden; $entry->save(); } else { Entry::create(['title' => $title, 'slug' => $slug, 'cover' => $cover, 'content' => $parsedContent, 'rawContent' => $rawContent, 'isHidden' => $isHidden]); } return redirect('/dashboard'); }
/** * Run the database seeds. * * @return void */ public function run() { Entry::truncate(); Entry::create(['name' => 'entry 1']); Entry::create(['name' => 'entry 2']); Entry::create(['name' => 'entry 3']); Entry::create(['name' => 'entry 4']); Entry::create(['name' => 'entry 5']); }
protected static function newItem($id, $name, $headers, $entries) { $item = Item::create(['section_id' => $id, 'name' => $name]); foreach ($headers as $header => $value) { ItemHeader::create(['item_id' => $item->id, 'name' => $header, 'value' => $value]); } foreach ($entries as $key => $entry) { Entry::create(['item_id' => $item->id, 'entry' => $entry, 'ordered' => $key]); } }
/** * Create a new entry. * * @param Request $request * @return Response */ public function store(Request $request) { $data = $request->all(); $validator = \Validator::make($data, ['seconds' => 'required|numeric']); if ($validator->fails()) { return response()->json(['errors' => $validator->errors()->all()], 400); } $user = \Auth::user(); $entry = Entry::create(['user_id' => (int) \Auth::user()->id, 'seconds' => (int) $data['seconds'], 'note' => !empty($data['note']) ? $data['note'] : null]); return response()->json($entry, 201); }
public function store() { $entry = Request::all(); $id = Entry::create($entry); $file = Request::file('filefield'); if ($file != null) { Storage::disk('local')->put('/allegato/' . $id->id . '/' . $file->getClientOriginalName(), File::get($file)); $id->filepath = '/allegato/' . $id->id . '/' . $file->getClientOriginalName(); $id->save(); } return redirect('entry'); }
public function newEntry(Request $request, $challengeType, $challenge_id) { $challenge = Challenge::findOrFail($challenge_id); if ($challenge->getEndDate() <= Carbon::now()) { abort(403, 'Challenge is already expired'); } else { $user = JWTAuth::parseToken()->authenticate(); $file = Input::file('file'); $newEntry = $request->all(); $newEntry['challenge_id'] = $challenge_id; $newEntry['user_id'] = $user->id; $entry = Entry::create($newEntry); $entry->saveFile($file); return $entry; } }
/** * Run the database seeds. * * @return void */ public function run() { // $this->call(UserTableSeeder::class); Model::unguard(); DB::table('users')->delete(); DB::table('admins')->delete(); DB::table('employees')->delete(); DB::table('entries')->delete(); $users = array(['name' => 'Ryan Chenkie', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'type' => 1], ['name' => 'Chris Sevilleja', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'type' => 3], ['name' => 'Holly Lloyd', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'type' => 2], ['name' => 'Adnan Kukic', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'type' => 2]); // Loop through each user above and create the record for them in the database foreach ($users as $user) { User::create($user); } Employee::create(['type' => 1, 'user_id' => 3]); Employee::create(['type' => 2, 'user_id' => 4]); Admin::create(['type' => 1, 'user_id' => 1]); Entry::create(['timeIn' => Carbon::now(), 'user_id' => 2]); Model::reguard(); }
public function postFormIndex(CreateEntryRequest $request) { $input = $request->all(); Entry::create($input); return response()->json(['status' => 'OK', 'message' => 'Formul nu a fost completat']); }
/** * Initially store the entry and send the user to Paypal for payment * @param Request $request */ public function store(Request $request) { // Get the data from the request $data = $request->all(); //dd($data); $user = Auth::user(); //1. Insert each competition entry into the database with 'unpaid' status foreach ($data['competitions'] as $competition_id => $detail_id) { if ($detail_id != "noEntry") { $entryData = array(); $entryData['user_id'] = $user->id; $entryData['event_id'] = $data['event_id']; $entryData['competition_id'] = $competition_id; $entryData['detail_id'] = $detail_id; $entryData['user_lastname'] = $user->lastname; $entryData['paymentStatus'] = 'unpaid'; $entryData['discounts_applied'] = $data['discounts_applied']; //Now insert the data //dd($entryData); Entry::create($entryData); } } //2. Insert question answers in to answers table if (key_exists('questions', $data)) { foreach ($data['questions'] as $question_id => $question_answer) { $answerData = array(); $answerData['question_id'] = $question_id; $answerData['competitor_id'] = $user->id; $answerData['event_id'] = $data['event_id']; if ($question_answer) { $answerData['answer'] = $question_answer; } //if "" then default will be "No answer given" as per schema. //create the answer //dd($answerData); Answer::create($answerData); } } //3. Insert any extras that have been ordered into orders table //dd($data['extras']); if (key_exists('extras', $data)) { foreach ($data['extras'] as $extra_id => $extraOrder) { $orderData = array(); $orderData['extra_id'] = $extra_id; $orderData['event_id'] = $data['event_id']; $orderData['user_id'] = $user->id; if ($extraOrder != "order") { //This is an extra order with an array of info if (array_key_exists('multiple', $extraOrder)) { $orderData['multiple'] = $extraOrder['multiple']; } if (array_key_exists('infoRequired', $extraOrder)) { $orderData['infoRequired'] = $extraOrder['infoRequired']; } } //create the extra order ExtraOrder::create($orderData); } } //4. Send off the payment request to paypal (success=success, fail=delete above) //send over the event id, then later grab all the entries for this // user from the database and change the status or delete as appropriate after paypal payment. $event = Event::findOrFail($data['event_id']); try { $transactionDescription = "Entry fees for " . $event->name . ": £" . $data['total']; $transaction = $this->gateway->purchase(array('amount' => $data['total'], 'currency' => 'GBP', 'description' => $transactionDescription, 'returnUrl' => 'http://foresightentries.app/entry/paid/' . $event->id, 'cancelUrl' => 'http://foresightentries.app/entry/cancelled/' . $event->id)); $transaction->setItems(array(array('name' => "Entry fees ({$event->name})", 'quantity' => '1', 'price' => $data['total']))); //SO THE BIG QUESTION HERE IS HOW DO I SEND THE PAYMENTS IN BITS TO ME AND //EVENT ORGANISER? Not right now. I'll do it manually at the closing date. $response = $transaction->send(); if ($response->isRedirect()) { $response->redirect(); } else { echo $response->getMessage(); //do something here, presumably redirect to an error page. } } catch (\Exception $e) { echo "Exception caught while attempting authorize.\n"; echo "Exception type == " . get_class($e) . "\n"; echo "Message == " . $e->getMessage() . "\n"; } }
function editTeam($id_game, $id_entry, $old_players, $email, Request $req) { $entry = $req->all(); $entry['id'] = $id_entry; $game = Game::get($id_game); $vld_approv = ['name' => 'required', 'password' => 'required', 'campus' => 'required|in:Cergy,Pau,Mixte', 'real_name.0' => 'required', 'p_name.0' => 'required', 'p_campus.0' => 'required|in:Cergy,Pau,Mixte', 'id' => 'required|numeric']; for ($i = 1; $i < $game->num_players; $i++) { $vld_approv['real_name.' . $i] = 'required_with:p_name.' . $i; $vld_approv['p_name.' . $i] = 'required_with:real_name.' . $i; } $vld = Validator::make($entry, $vld_approv); if ($vld->fails()) { if ($req->is('light/*')) { return redirect()->back()->with('errors', $vld->messages()->all())->with('entry', $entry); } return response()->json($vld->messages()->all(), 400); } $team = $req->only('name', 'password', 'campus'); $team['id'] = $id_entry; $team['real_name'] = ''; if (Entry::update($team) == 0) { if ($req->is('light/*')) { return redirect()->back()->with('errors', ["Mot de passe non valide."])->with('entry', $entry); } return response()->json(["Mot de passe non valide."], 400); } $i = 0; while ($req->input('p_name.' . $i) || !empty($old_players[$i])) { if (empty($req->input('p_name.' . $i))) { Entry::delete($old_players[$i]->rowid, $req->input('password')); } else { if (!empty($old_players[$i])) { Entry::update(['id' => $old_players[$i]->rowid, 'real_name' => $req->input('real_name.' . $i), 'name' => $req->input('p_name.' . $i), 'campus' => $req->input('p_campus.' . $i) || $players[0]['p_campus'], 'password' => $req->input('password')]); } else { Entry::create(['real_name' => $req->input('real_name.' . $i), 'name' => $req->input('p_name.' . $i), 'campus' => $req->input('p_campus.' . $i) || $players[0]['p_campus'], 'id_team' => $id_entry, 'password' => Hash::make($req->input('password')), 'time' => time(), 'email' => $email, 'id_game' => $id_game]); } } $i++; } if ($req->is('light/*')) { return redirect('light/' . $id_game); } return response()->json("success"); }