/** * Find By longitude latitude * @param Request $request [description] * @return Hexcores\Api\Facades\Response */ public function find(Request $request) { $lat = (double) $request->input('lat'); $long = (double) $request->input('lon'); $data = $this->transform($this->model->findIntersects($long, $lat), new GeoTransformer(), true); return response_ok($data); }
public function updateArticle(Request $request, $id) { $article->title = $request->input('title'); $article->content = $request->input('content'); $article->save(); return response()->json($article); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { // error_log("------------------------------------------------------"); $Mailer = new Email(); $Mailer->email = $request['email']; /* $validator class with method fails() */ $validator = Validator::make($request->all(), ['email' => 'required|email']); /* $isNewEmail = true: no email found in db false: duplicate email found in db */ $isNewEmail = collect($Mailer->where('email', $Mailer->email)->get())->isEmpty() ? true : false; if ($validator->fails()) { error_log(json_encode(['error' => ['invalid_email' => $request->all()]])); return response()->json(['error' => 'E-mail is invalid'])->setCallback($request->input('callback')); } elseif (!$isNewEmail) { error_log(json_encode(['error' => ['duplicate_email' => $request->all()]])); return response()->json(['error' => 'E-mail is marked as being subscribed'])->setCallback($request->input('callback')); return redirect('/')->withErrors($validator)->withInput(); } else { error_log(json_encode(['mailer' => ['newEmail' => $Mailer]])); // soon $Scribe = $this->subscribe($Mailer->email); // soon error_log(json_encode(['scribe' => $Scribe])); $Mailer->save(); return response()->json(['success' => true])->setCallback($request->input('callback')); } }
/** * Send campagne * * @return \Illuminate\Http\Response */ public function campagne(Request $request) { // Get campagne $campagne = $this->campagne->find($request->input('id')); $date = $request->input('date', null); //set or update html $html = $this->worker->html($campagne->id); $this->mailjet->setList($campagne->newsletter->list_id); // list id // Sync html content to api service and send to newsletter list! $response = $this->mailjet->setHtml($html, $campagne->api_campagne_id); if (!$response) { throw new \designpond\newsletter\Exceptions\CampagneUpdateException('Problème avec la préparation du contenu'); } /* * Send at specified date or delay for 15 minutes before sending just in case */ $toSend = $date ? \Carbon\Carbon::parse($date) : \Carbon\Carbon::now()->addMinutes(15); $result = $this->mailjet->sendCampagne($campagne->api_campagne_id, $toSend->toIso8601String()); if (!$result['success']) { throw new \designpond\newsletter\Exceptions\CampagneSendException('Problème avec l\'envoi' . $result['info']['ErrorMessage'] . '; Code: ' . $result['info']['StatusCode']); } // Update campagne status $this->campagne->update(['id' => $campagne->id, 'status' => 'envoyé', 'updated_at' => date('Y-m-d G:i:s'), 'send_at' => $toSend]); alert()->success('Campagne envoyé!'); return redirect('build/newsletter'); }
public function update(ServiceMonth $service_month, Request $request) { $input['hours_used'] = $request->input('hours_logged'); $input['description'] = $request->input('description'); $service_month->update($input); return $service_month->toJson(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { $rules = ['username' => 'required', 'password' => 'required', 'age' => 'required|integer']; try { $user = User::find($id); if (!$user) { return response()->json(['code' => 404, 'messages' => 'User not found.'], 404); } $username = $request->input('username'); $password = $request->input('password'); $age = $request->input('age'); if ($username) { $user->username = $username; } if ($password) { $user->password = $password; } if ($age) { $user->age = (int) $age; } $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(['code' => 422, 'messages' => $validator->errors()->all()], 422); } if ($age < 18) { return response()->json(['code' => 422, 'messages' => 'Age field must be greater than 18'], 422); } $user->save(); return response()->json(['code' => 200, 'data' => $user], 200); } catch (Exception $e) { return response()->json(['code' => 500, 'messages' => 'Internal Server Error'], 500); } }
public function doAddInvoice(Request $request) { $invoice = Invoice::addNew($request->input('description'), $request->input('total_cost')); $invoice->attachToLabWork($request->input('lab_work_id')); $invoice->addInvoiceFile($request->file('invoice_file')); return redirect()->to('lab-work')->with('invoice-added'); }
public function postChangePassword() { $newPassword = $this->request->input('password'); $token = $this->request->input('spToken'); $validator = $this->loginValidator(); if ($validator->fails()) { if ($this->request->wantsJson()) { return $this->respondWithError('Validation Failed', 400, ['validatonErrors' => $validator->errors()]); } return redirect()->to(config('stormpath.web.changePassword.uri') . '?spToken=' . $token)->withErrors($validator); } $application = app('stormpath.application'); try { $application->resetPassword($token, $newPassword); // the password has been changed. Time to fire the // `UserHasResetPassword` event // Event::fire(new UserHasResetPassword()); if ($this->request->wantsJson()) { return $this->respondOk(); } return redirect()->to(config('stormpath.web.changePassword.nextUri')); } catch (\Stormpath\Resource\ResourceError $re) { if ($this->request->wantsJson()) { return $this->respondWithError($re->getMessage(), $re->getStatus()); } return redirect()->to(config('stormpath.web.changePassword.errorUri'))->withErrors(['errors' => [$re->getMessage()]]); } }
public function addHelp(Request $request, $id) { $event = Event::findOrFail($id); if (!$event->activity) { $request->session()->flash('flash_message', 'This event has no activity data.'); return Redirect::back(); } $amount = $request->input('amount'); if ($amount < 1) { $request->session()->flash('flash_message', 'The amount of helpers should be positive.'); return Redirect::back(); } $committee = Committee::findOrFail($request->input('committee')); $help = HelpingCommittee::create(['activity_id' => $event->activity->id, 'committee_id' => $committee->id, 'amount' => $amount]); foreach ($committee->users as $user) { $name = $user->name; $email = $user->email; $helptitle = $help->activity->event->title; Mail::queue('emails.committeehelpneeded', ['user' => $user, 'help' => $help], function ($m) use($name, $email, $helptitle) { $m->replyTo('*****@*****.**', 'S.A. Proto'); $m->to($email, $name); $m->subject('The activity ' . $helptitle . ' needs your help.'); }); } $request->session()->flash('flash_message', 'Added ' . $committee->name . ' as helping committee.'); return Redirect::back(); }
public function writeBlog(Request $request) { date_default_timezone_set('Asia/Shanghai'); $title = $request->input('title', ''); $label = $request->input('type', ''); $content = $request->input('content', ''); $pretitle = $request->input('pretitle', ''); $privacy = $request->input('privacy'); if ($content != '' && $title != '') { if ($pretitle != '') { $essay_id = DB::select('select id from essay where title = ?', [$pretitle]); DB::delete('delete from essay where title = ?', [$pretitle]); DB::delete('delete from label where essay_id = ?', [$essay_id[0]->id]); } DB::table('essay')->insert(['title' => $title, 'author' => 'sunji', 'date' => date('Y-m-d H:m:s'), 'content' => EndaEditor::MarkDecode($content), 'previledge' => $privacy]); $essay_id = DB::select('select id from essay where title = ?', [$title]); if ($label != "") { $retArr = explode(',', $label); foreach ($retArr as $a) { if ($a == '') { continue; } DB::table('label')->insert(['label' => $a, 'essay_id' => $essay_id[0]->id]); } } } else { echo "NULL CONTENT"; } return redirect('/blog/newlist'); }
public function nuevo(Request $request) { //recibir los datos del request //instanciar una nueva persona //guardar en la base $apellido = $request->input("apellido"); $nombre = $request->input("nombre"); $documento = $request->input("documento"); /*$sexo = $request ->input("sexo"); $nacionalidad = $request ->input("nacionalidad"); $archivosExt = $request ->input("archivos_externos"); $fechaExp = $request ->input("fecha_expedicion"); $fechaVenc = $request ->input("fecha_vencimiento"); $domicilio = $request ->input("domicilio"); $ciudad = $request ->input("ciudad"); $departamento = $request ->input("departamento"); $provincia = $request ->input("provincia"); $fechaNac = $request ->input("fecha_nacimiento"); $ugarNac = $request ->input("lugar_nacimiento");*/ $reglas = ['apellido' => 'required|min:3|max:50', 'nombre' => 'required|min:3|max:50', 'documento' => 'required|min:8|max:99999999']; //validamos... $this->validate($request, $reglas); $clientes = new Cliente(); $clientes->apellido = $apellido; $clientes->nombre = $nombre; $clientes->documento = $documento; $clientes->save(); return redirect('clientes'); }
/** * Responds to requests to POST /users */ public function postIndex(Request $request) { // create Faker instance $faker = Faker\Factory::create(); // Get user options $phone = $request->input('phone'); // Should a phone number be displayed $address = $request->input('address'); // Should a full or partial address be displayed // Generate required information $userName = $faker->name(); $userCity = $faker->city(); $userState = $faker->stateAbbr(); // Check for and generate optional information, else set deselected variables to null if ($address == 1) { $userStreet = $faker->streetAddress(); $userZip = $faker->postcode(); } else { $userStreet = null; $userZip = null; } if ($phone == 1) { $userPhone = $faker->phoneNumber(); } else { $userPhone = null; } // Send user information to View return view('users.index')->with('userName', $userName)->with('userStreet', $userStreet)->with('userCity', $userCity)->with('userState', $userState)->with('userZip', $userZip)->with('userPhone', $userPhone); }
public function save(Request $request, $id) { $status = new Status(); $status->problem_id = $id; $status->user_id = '0'; $status->time = '0'; $status->memory = '0'; $leng = $request->input('leng'); $status->language = $leng; //$status->source_code= $status->save(); $status = Status::orderby('solution_id', 'desc')->first(); $compile = new Compileinfo(); $compile->solution_id = $status->solution_id; $compile->save(); $code = new Source_code(); $code->solution_id = $status->solution_id; $code->source = $request->input('editor'); $code->save(); $code = Source_code::orderby('sourcecode_id', 'desc')->first(); $run = new Run(); $run->solution_id = $status->solution_id; $run->problem_id = $id; $run->language = $leng; $run->sourcecode_id = $code->sourcecode_id; $run->save(); return redirect('status/status'); }
public function post($id, Request $request) { $idEvaluation = Evaluation::join('type_evaluations', 'type_evaluations.id', '=', 'evaluations.type_evaluation_id')->where('evaluations.id', $id)->first(); $criteres = CritereTypeEvaluation::join('criteres', 'criteres.id', '=', 'critere_type_evaluation.critere_id')->where('type_evaluation_id', $idEvaluation->type_evaluation_id)->get(); //$enseignant = EnseignantEvaluationRole::where('enseignant_id', ) // ->where('evaluation_id', $id) // ->first(); $total = 0; foreach ($criteres as $key => $critere) { //enseignant_id dans le foreach à rajouter CritereEnseignantEvaluation::insert([['noteCritere' => $request->input('critere' . $critere->critere_id), 'critere_id' => $critere->critere_id, 'enseignant_id' => 4, 'evaluation_id' => $id]]); $total = $total + $request->input('critere' . $critere->critere_id); } //if ($enseigant->role_id==1) { // $total=($total+$idEvaluation->noteGroupe)/2; //} Evaluation::where('evaluations.id', $id)->update(['noteGroupe' => $total]); //mettre le jury en à voté EnseignantEvaluationRole::where('enseignant_id', 4)->where('evaluation_id', $id)->update(['vote' => 1]); //retour selon maitre ou esclave //if ($enseigant->role_id==1) { // return redirect()->action('RecapitulationController@show',$id); //}else{ // return redirect()->action('GroupeProjetController@index'); //} return redirect()->action('RecapitulationController@show', $id); }
public function sectionTitle(Request $request) { $input = $request->input(); $template = view()->file(app_path('Http/Templates/section-title.blade.php'), $request->input()); Session::flash('data', $input); return view('items.show')->with(['template' => $template]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { for ($i = 0; $i < count($request->all()); $i++) { $data = ['nome_modulo' => $request->input($i . '.nome_modulo'), 'carga_horaria_modulo' => $request->input($i . 'carga_horaria_modulo'), 'curso_id' => 1]; Modulo::create($data); } }
public function postImport(Request $req) { $color = ['red', 'pink', 'blue', 'purple', 'green', 'yellow', 'indigo', 'cyan', 'lime', 'brown', 'orange', 'gray']; $data = []; $status = true; if ($req->input('tags')) { $data = explode("\n", $req->input('tags')); for ($i = 0; $i < count($data); $i++) { list($cate, $name) = explode('-', $data[$i]); $category = DB::table('categories')->where('name', $cate)->first(); $cateId = 0; if ($category) { $cateId = $category->id; } else { $cateId = DB::table('categories')->insertGetId(['name' => $cate, 'color' => $color[rand(0, count($color) - 1)]]); } $tag = Tag::where('name', $name)->first(); if ($tag) { $tag->category_id = $cateId; $tag->save(); } else { Tag::create(['name' => $name, 'category_id' => $cateId]); } } } return ['status' => $status, 'tags' => $this->getIndex()]; }
public function update(Request $request) { $user = User::find($request->input('id')); $user->role = $request->input('role'); $user->save(); return Redirect::back()->with('message', 'User is successfully updated !'); }
public function post(Request $request) { $id = $request->input('id'); $validate = Validator::make($request->all(), Equipment::$validation_rules); if ($validate->passes()) { $equipment_id = $request->input('equipment_id'); $name = $request->input('name'); $rate = $request->input('rate'); if ($id != "") { $equipment = Equipment::find($id); } else { $equipment = new Equipment(); } $equipment->equipment_id = $equipment_id; $equipment->name = $name; $equipment->rate = $rate; if ($equipment->save()) { if ($id != "") { return redirect()->action('EquipmentController@add', $id)->with('success', 'Equipment has been successfully saved'); } else { return $this->redirect_to_equipment_add->with('success', 'Equipment has been successfully saved'); } } else { return $this->redirect_to_equipment_add->with('error', 'Equipment save error'); } } else { if ($id != "") { return redirect()->action('EquipmentController@add', $id)->with('success', 'Equipment has been successfully saved'); } else { return $this->redirect_to_equipment_add->withErrors($validate)->withInput(); } } }
public function guardar(Request $request) { $codigo = $request->input('codigo'); $entrada = Entrada::where('codigo', $codigo)->first(); $entrada->base_grava = $request->input('Esubtotal'); $entrada->total = $request->input('Etotal'); $detalles = DetalleEntrada::where('compra_id', $entrada->codigo)->get(); foreach ($detalles as $key => $value) { $producto = Producto::where('codigo', $value->producto_id)->first(); $producto->stock += $value->cantidad; $producto->save(); } $entrada->estado = 1; $entrada->save(); $kardex = new Kardex(); $kardex->factcmp_id = $entrada->codigo; $kardex->tipo_entrdsald = 1; $kardex->estado = 1; $kardex->save(); $empresa = Empresa::where('id', 1)->first(); $empresa->conse_entrada = $entrada->codigo; $empresa->save(); $msg = 'Se ha guardado la entrada.'; return redirect()->route('entradas')->with('status', $msg); }
/** * @POST("/uploading_data") * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function uploading_data(Request $request) { $photos = $request->input('photos'); $category_id = $request->input('category_id'); if ($request->input('shop_id')) { $shop_id = $request->input('shop_id'); $shop = Shops::find($shop_id); if ($shop && !$shop->canAddItem()) { return redirect()->route('shops.my'); } foreach ($photos as $photo) { foreach ($photo as $item) { $attachment = new Attachment(); $attachment->name = $item['aid']; $attachment->path = $item['src_big']; $attachment->url = $item['src_big']; $attachment->save(); $shop_item = new ShopItems(); $shop_item->name = 'Название'; $shop_item->description = $item['text']; $shop_item->shop_id = $shop_id; $shop_item->category_id = $category_id; if ($attachment) { $shop_item->attachment()->associate($attachment); } $shop_item->save(); } } } }
public function index(Request $request) { $command = $request->input('text', null); $userName = $request->input('user_name', 'mate'); $params = []; $params['command'] = $command; $params['user_name'] = $userName; if (empty($command)) { return response()->json("Sorry {$userName}, I don't know what you're talking about !"); } $hint = explode(' ', $command)[0]; switch ($hint) { case 'list': $results = $this->lodges->index(); $response = sizeof($results) ? $results : 'Sorry, no Lodges right now. Would you please feed me some'; break; case 'add': $this->dispatch(new CreateLodge($params)); $response = "Thanks {$userName}, I am working on it, will inform you when I am done."; break; default: $response = "God dammit {$userName}, read the FU*&king manual"; break; } return response()->json($response); }
/** * Function to store custom field * * @access public * @param \Illuminate\Http\Request $request * @param \Syscover\Pulsar\Models\CustomFieldGroup $customFieldGroup * @param string $resource * @param integer $objectId * @param string $lang * @return void */ public static function storeCustomFieldResults($request, $customFieldGroup, $resource, $objectId, $lang) { $customFieldGroup = CustomFieldGroup::find($customFieldGroup); $customFields = CustomField::getRecords(['lang_026' => $lang, 'group_id_026' => $customFieldGroup->id_025]); $dataTypes = collect(config('pulsar.dataTypes'))->keyBy('id'); $customFieldResults = []; foreach ($customFields as $customField) { // if we return an array but the data to be saved is not an array, we will keep as many records containing the array elements if (is_array($request->input($customField->name_026 . '_custom')) && $dataTypes[$customField->data_type_id_026]->type != 'array') { foreach ($request->input($customField->name_026 . '_custom') as $value) { $customFieldResult = ['object_id_028' => $objectId, 'lang_id_028' => $lang, 'resource_id_028' => $resource, 'field_id_028' => $customField->id_026, 'data_type_type_028' => $dataTypes[$customField->data_type_id_026]->type, 'value_028' => $value]; $customFieldResults[] = $customFieldResult; } } else { $customFieldResult = ['object_id_028' => $objectId, 'lang_id_028' => $lang, 'resource_id_028' => $resource, 'field_id_028' => $customField->id_026, 'data_type_type_028' => $dataTypes[$customField->data_type_id_026]->type]; // if we return an array and the data to be saved is an array, the array will keep like string expression. // using insert not access to mutators on Syscover\Pulsar\Models\CustomFieldResult to change the value type of a string to array automatically // we have to do manually casting if (is_array($request->input($customField->name_026 . '_custom')) && $dataTypes[$customField->data_type_id_026]->type == 'array') { $customFieldResult['value_028'] = implode(',', $request->input($customField->name_026 . '_custom')); } else { // get value and record in your field data type, add suffix '_custom' to avoid conflict with other field names if ($dataTypes[$customField->data_type_id_026]->type == 'boolean') { $customFieldResult['value_028'] = $request->has($customField->name_026 . '_custom'); } else { $customFieldResult['value_028'] = $request->input($customField->name_026 . '_custom'); } } $customFieldResults[] = $customFieldResult; } } if (count($customFieldResults) > 0) { CustomFieldResult::insert($customFieldResults); } }
public static function savePermission(Request $request, $id = null) { $permission = $id == null ? new Permission() : self::getPermission($id); $permission->permission_name = $request->input("permission_name"); $permission->role_id = $request->input("role_id"); $permission->save(); }
public function postLogin(\Illuminate\Http\Request $request) { $username = $request->input('username'); $password = $request->input('password'); // First try to log in as a local user. if (Auth::attempt(array('username' => $username, 'password' => $password))) { $this->alert('success', 'You are now logged in.', true); return redirect('users/' . Auth::user()->id); } // Then try with ADLDAP. $ldapConfig = \Config::get('adldap'); if (array_get($ldapConfig, 'domain_controllers', false)) { $adldap = new \adldap\adLDAP($ldapConfig); if ($adldap->authenticate($username, $password)) { // Check that they exist. $user = \Ormic\Model\User::where('username', '=', $username)->first(); if (!$user) { $user = new \Ormic\Model\User(); $user->username = $username; $user->save(); } \Auth::login($user); //$this->alert('success', 'You are now logged in.', TRUE); return redirect(''); //->with(['You are now logged in.']); } } // If we're still here, authentication has failed. return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']); }
/** * Store a newly created resource in storage. * * @param Request $request * @param URI int $fact_id * @return Response */ public function store(Request $request, $user_id = null, $fact_id = null) { if (!$request->input('tag_name')) { return $this->respondUnprocessed(); } $fact = Fact::find($fact_id); if ($user_id) { $authUser = Auth::ID(); if ($authUser != $user_id) { return $this->respondForbidden("Unauthorized: Must be logged to access endpoint"); } if ($fact->user_id != $user_id) { return $this->respondForbidden("Unauthorized: Verify you still have access to resource"); } } if (!$fact) { return $this->respondNotFound("Fact Not found"); } else { $tag_name = $request->input('tag_name'); $tag = Tag::firstOrCreate(['tag_name' => $tag_name]); if ($tag) { TaggedFact::create(['fact_id' => $fact_id, 'tag_id' => $tag->id]); $metadata = ['tag_id' => $tag->id]; return $this->respondCreated("Request Successful", $metadata); } else { return $this->respondUnprocessed("Unable to tag the fact"); } } }
public function index(Request $request) { $scope = []; if ($request->has('title')) { $scope['title'] = ['LIKE', '%' . $request->input('title') . '%']; } if ($request->has('host')) { $scope['host'] = ['LIKE', '%' . $request->input('host') . '%']; } if ($request->has('introduction')) { $scope['introduction'] = ['LIKE', '%' . $request->input('introduction') . '%']; } $params = $request->except('page'); if ($request->has('sort')) { $params['sort'] = $request->input('sort'); } else { $params['sort'] = 'id'; } if ($request->has('order')) { $params['order'] = $request->input('order'); } else { $params['order'] = 'desc'; } $fts = Ft::select('id', 'title', 'host', 'poster_url', 'introduction')->multiwhere($scope)->orderBy($params['sort'], $params['order'])->paginate(30); return view('ft.index', ['params' => $params, 'fts' => $fts]); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { $metodo = $request->method(); $fabricante = Fabricante::find($id); if (!$fabricante) { return response()->json(['mensaje' => 'No se encuentra este fabricante', 'codigo' => 404], 404); } if ($metodo === 'PATCH') { $bandera = false; $nombre = $request->input('nombre'); if ($nombre != null && $nombre != '') { $fabricante->nombre = $nombre; $bandera = true; } $telefono = $request->input('telefono'); if ($telefono != null && $telefono != '') { $fabricante->telefono = $telefono; $bandera = true; } if ($bandera) { $vehiculo->save(); return response()->json(['mensaje' => 'Vehiculo editado'], 200); } return response()->json(['mensaje' => 'No se modificó ningun vehiculo'], 200); } $nombre = $request->input('nombre'); $telefono = $request->input('telefono'); if (!$nombre || !$telefono) { return response()->json(['mensaje' => 'No se pudieron procesar los valores', 'codigo' => 422], 422); } $fabricante->nombre = $nombre; $fabricante->telefono = $telefono; $fabricante->save(); return response()->json(['mensaje' => 'Fabricante editado'], 200); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { //getting all point when no search is done $allpoint = FarmerPoint::orderBy('name'); //listing for drop down search $farmerPointList = FarmerPoint::Lists('name', 'id'); $districtList = District::Lists('name', 'id'); //form data receiving $point_name = $request->input('id'); $point_district = $request->input('district_id'); $phone = $request->input('phone'); if (!empty($phone)) { $allpoint->Where('phone', 'LIKE', '%' . $phone . '%'); } if (!empty($point_name)) { //filtering allpoint with name $allpoint->Where('id', 'LIKE', '%' . $point_name . '%'); } if (!empty($point_district)) { //filtering allpoint with district $allpoint->Where('district_id', $point_district); } $allpoint = $allpoint->paginate(10); return view('frontend.pointlist', ['allpoint' => $allpoint, 'farmerPointList' => $farmerPointList, 'districtList' => $districtList]); }
public function update(Request $request) { $tweet = Tweet::find($request->input('tweet_id')); $tweet->tweet = $request->input('tweet'); $tweet->save(); return redirect('tweet'); }