update URL as input value - php

I have a search box and when I enter the code in that search box it should show the required data on the web page. but I'm unable to fetch data by using the search box. because I am unable to send that code to my controller which is entered in the search box.
As well as when I am submitting the code in the search box the browser URL should replace that code (It is like an edit function)
So, can someone help me to get it done? The following code shows what I have done.
Thank You, everyone!
{!! Form::open(['action' => ['Account\CodeController#codeResult', 'code'=> 'code'], 'method' => 'get' , 'class'=>"col12"]) !!}
<div class="row mb-5">
<div class="col-4 mx-auto">
<div class="text-input-with-icon">
<span class="fa fa-search form-control-feedback float-right"></span>
<input type="text" name="search" value="" id="barcode" placeholder="Search By code">
</div>
</div>
<div class="col-2 mx-auto">
<button type="submit" name="code" value="name" class="btn btn-reset">SEARCH
</button>
</div>
</div>
{!! Form::close() !!}

Related

How to fetch and update data in Laravel

So, I have two fields. In the first field I want to add old data and in the second field I want to add new data, and below those fields is a button which when clicked will fetch the data from Mongo Table and update the data inside.
I have tried implementing various logic but still no luck. Any sort of help would be appreciated.
This is my controller code:
public function updatedockets($dockets){
if (!Session::has('user_id')){
return Redirect::to('/login');
}
$cart = \App\Models\Cart::where('tracking_no',$dockets)->get()->toArray();
foreach ($cart as $value) {
$cart = \App\Models\Cart::where('tracking_no')->update(['tracking_no' => $dockets]);
}
}
This is my view code:
<div role="tabpanel" class="tab-pane" id="docket-replace">
<form method="post" id="frmDocket" action="/admin/viewdockets">
{!! csrf_field() !!}
<div>
<div class="form-group">
<textarea id="txtreploaceDockets" name="replacedockets" class="form-control" rows="15" placeholder="Enter old docket(s) here. Don't put more than 1000 docket numbers, all dockets should be comma(,) or new line separated"></textarea>
</div>
</div>
</form>
<form method="post" id="frmDocket" action="/admin/viewdockets">
{!! csrf_field() !!}
<div>
<div class="form-group">
<textarea id="txtreplaceDockets" name="replacedockets" class="form-control" rows="15" placeholder="Enter new docket(s) here. Don't put more than 1000 docket numbers, all dockets should be comma(,) or new line separated"></textarea>
</div>
<div class="form-group">
<div class="text-right pr-sm-15 pb-sm-15">
<button type="button" class="btn btn-primary btn-xs" id="btnReplaceDocketData" onclick="return confirm('Are you sure that you have entered the right docket number?')"> Replace Docket </button>
</div>
</div>
</div>
</form>
</div>
As you're not using $value, maybe below code helps you:
$cart = \App\Models\Cart::where('tracking_no', $dockets)
->update(['tracking_no' => $dockets]);
Sample:
$course->statuses()->updateOrCreate(
['status_id' => $id],
['status' => $request->get('status'), 'status_type' => Course::class]
);`

Save editable text on input and save into db

I have an input for a bitcoin wallet address, but I need 13 more, and this code is very long and would be huge, besides I've tried this way and it didn't work. How you would do this simply?
This alone works very well, the user has the wallet you want and clicks update and is saved in the database.
My html:
<form role="form" method="post" action="">
{{ csrf_field() }}
{{ method_field('POST') }}
<span><i>Wallet:</i></span>
<small id="emailHelp" class="form-text text-muted text-center">
<div class="input-group">
<input type="text" class="form-control" placeholder="Bitcoin wallet code" name="bitzpayer_id2" value="{{old('bitzpayer_id2') ? old('bitzpayer_id2') : Auth::user()->bitzpayer_id2}}"/>
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-info">Update</button>
</span>
</div>
</small>
</form>
You can make 13 different form with a hidden text field called id.
<input type="hidden" id="{{ $id }}" />
Then you will have your desired request data.

how to retrieve data from database into input values of a form in laravel php to complete the update action?

I'm trying to populate data into input values from mysql database so that I can see and change the data.
I have a form named form.blade.php which will be included in both create.blade.php and edit.blade.php.
What I need is to know is how to retrive data from database to populate data to those inputs when I click on edit.Then when I click on Add button in index.blade.php ,I'll be redirected to create.blade.php and then inputs must be empty.
I tried to add some code functions to every input value
{{old('title',$page->title}} then {{ isset($page) ? page->title: ''}}
but its not working
I'm using one form to perform create and update actions
This is the edit.blade.php
#extends('layouts.master')
#section('content')
<div class="card">
<div class="card-header card-header-success">
<h4 class="card-title ">Pages Data Table</h4>
<p class="card-category"> Here you can update Page data</p>
</div>
<div class="card-body">
{!! Form::open(['action' => 'PagesController#store', 'method' => 'POST' ]) !!}
#csrf
#method('PUT')
#include('pages.includes.form')
{!! Form::close() !!}
</div>
</div>
#endsection
and this is the child form form.blade.php
<div class="form-group">
{{Form::label('title', 'Title')}}
{{ Form::text('title', '',['class' => 'form-control', 'placeholder' => 'Title']) }}
</div>
<div class="form-group">
{{Form::label('content', 'Content')}}
<br>
{{ Form::textarea('content', '',['class' =>'form-control', 'placeholder'=> 'Content']) }}
</div>
<div class="form-group">
<div class="form-check form-check-radio">
<label class="form-check-label">
{{Form::input('radio','status', '0',['class' => 'form-check-input','checked'=>'checked'])}} Status Off
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="form-check form-check-radio">
<label class="form-check-label">
{{Form::input('radio','status', '1',['class' => 'form-check-input'])}} Status On
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
</div>
<input type="submit" name="submit" class="btn btn-success" value="Save">
When you are using the same form for create and update, you can use the optional method.
<input type="text" class="form-control{{ $errors->has('date') ? ' is-invalid' : '' }}" name="date" id="date" value="{{ old('date', optional($expense)->date) }}">
In the create function send the variable as null like $expense = null;
And in edit function the variable has its own value from database. So when the variable has its value the input field will be filled by value from database otherwise it will be empty.

Insert data use tinymce in laravel. but display showing css style. how to remove css style in display

Form Code
{!!Form::open(['url'=>'/about/save','method'=>'POST','enctype'=>'multipart/form-data'])!!}
<div class="form-group">
<label for="exampleFormControlInput1">add about</label>
<textarea type="text" class="form-control" id="exampleFormControlInput1" name="text"></textarea>
{{$errors->has('text')?$errors->first('text'):''}}
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Save</button>
</div>
{!!Form::close()!!}
display form image:
font page display with CSS code:
Display your data in view with {!! $text !!} not with {{ $text }}.

Resizing bootstrap form box not working when <span> tag is removed

I'm trying to resize a form box using .col-md-12. It works fine if I keep the code inside the span tag as it is, but if I take it off (and I want to, because I need to remove that button) it stops working. In this scenario the form box will maintain some kind of default size, no matter which value is inserted after -md.
Could anyone give some help? If it matters, this HTML file is part of the viewer of a project using laravel framework.
<div class="box-body">
<div class="col-md-12">
<div class="form-group">
<label for="name">{{ 'name' }}</label>
<div class="input-group">
<input class="form-control" type="text" name="name" value="{{ $name }}">
<span class="input-group-btn">
<a class="btn btn-warning" href="{{ url('path', $id) }}" title="{{ 'edit' }}"><i class="fa fa-pencil"></i></a>
</span>
</div>
</div>
</div>
</div>
Provided that I understood your question right, just add the btn class to the span tag and remove the a tag.
<span class="input-group-btn btn">
<!-- removed button -->
</span>

Categories