jhansi

Experience

5,580

0 Best Reply Awards

  • Member Since 9 Months Ago
  • 21 Lessons Completed
  • 0 Favorites

5th May, 2017

jhansi started a new conversation Does Any One How To Disable X CSRF Token Request Header? • 4 months ago

timesheet.blade.php

@extends('layouts.app')
@section('content')
<div class="container">
   <div class="container">
   <style>
  td {overflow:hidden;}
  .wrapword{
white-space: -moz-pre-wrap !important;  /* Mozilla, since 1999 */
white-space: -pre-wrap;      /* Opera 4-6 */
white-space: -o-pre-wrap;    /* Opera 7 */
white-space: pre-wrap;       /* css-3 */
word-wrap: break-word;       /* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
.glyphicon {
    font-size: 25px;
};
</style>
    <div class="row">
    {!! Breadcrumbs::render('regtime/listing') !!}
        <div class="col-md-15 col-md-offset-0">
        @if ($message = Session::get('success'))
                    <div class="alert alert-success" role="alert">
                        {{ Session::get('success') }}
                    </div>
                @endif
                @if ($message = Session::get('error'))
                    <div class="alert alert-danger" role="alert">
                        {{ Session::get('error') }}
                    </div>
                @endif
                <?php
if (Session::has('sheettd')) {
    $dropDownVal = session()->get('sheettd');
} else {
    $dropDownVal = '';
}
?>
                <div style="border: 4px solid #a1a1a1;margin-top: 15px;padding: 20px;">
                <select id="imports2" onchange="show_selected1()">
          <option selected = "selected" value="">Select...</option>
          <option value="today" <?php if ($dropDownVal=='today') echo 'selected="selected"'; ?>>Today</option>
          <option value="7day" <?php if ($dropDownVal=='7day') echo 'selected="selected"'; ?>>7 Day ago  </option>
          <option value="datediff" <?php if ($dropDownVal=='datediff') echo 'selected="selected"'; ?>>Custom Range</option>
        </select>
        @if ($dropDownVal == 'datediff')
          <form id="ddsubmit" action="{{ URL::to('/searchsheet/') }}" method="post">{{ csrf_field() }}<div class="col-md-3"><input name="from_date" id="from_date" class="form-control" placeholder="From Date" value= "{{Session::get('fd')}}" required/></div><div class="col-md-3"><input name="to_date" id="to_date" class="form-control" placeholder="To Date" value="{{Session::get('td')}}" required/></div><div class="col-md-5"><button class="btn btn-info" />Submit</button></div><br /></form><br />
         
        @endif
        
        <form id="hh" class = "hh" type="submit"</form><button>Submit</button></form>
            
<div>
<form id="importexport" action="{{ URL::to('importExcelS') }}" class="form-horizontal" method="post" enctype="multipart/form-data">{{ csrf_field() }} <input type="file" name="import_file" /> <br /> <button class="btn btn-primary">Import CSV or Excel File</button></form><br />
<a href="{{ url('downloadExcelS/xls') }}"><button id="se" class="btn btn-success btn-lg">Download Excel xls</button></a> <a href="{{ url('downloadExcelS/xlsx') }}"><button id="see" class="btn btn-success btn-lg">Download Excel xlsx</button></a> <a href="{{ url('downloadExcelS/csv') }}"><button id="seee" class="btn btn-success btn-lg">Download CSV</button></a>
</div>
</div>
            <div class="panel panel-default">
    <table  class="table table-bordered user" width = "1000" style = "table-layout: fixed" >
    <div class="panel-heading">List of Tasks</div>
 
        <tr>
            <th>Date Created</th>
            <th>Project</th>
            <th>Ticket Number</th>
            <th>Ticket Subject</th>
            <th>Hours</th>
            <th>Action</th>
        </tr>
        @foreach ($sheet as $sheets)
            <tr>
                <td data-format="yyyy-mm-dd">{{ $sheets->date }}</td>
                <td>{{ $sheets->Project}}</td>
                <td>{{ $sheets->TicketNumber}}</td>
                <td class="wrapword">{!! clean($sheets->task) !!}</td>
                <td data-format="[HH]:MM:SS"> <?php $date1 = date_create($sheets->time_out);
                             $date2 = date_create($sheets->time_in);
                             $mins = date_diff($date1,$date2);
                             $hour = $mins->format('%h');
                             $minute = $mins->format('%i');
                             $seconds = $mins->format('%s');
                             echo $hour.' Hours <br />'.$minute.' Minutes <br />'.$seconds.' Seconds';?></td>
                 <td class="center"><a class ="delete" href ="{{URL::to('/regtime/delete/'. $sheets->timesheet_id) }}"><span class="glyphicon glyphicon-remove-sign"></span><a href="{{URL::to('/timesheetedit/'.$sheets->timesheet_id) }}"><span class ="glyphicon glyphicon-pencil"></span></a>
                 </td>
            </tr>
        @endforeach
    @endsection
    @section('js')    
    <script type="text/javascript">
                        $(".delete").click(function(e){
                            e.preventDefault();
                            href = this.href;
              bootbox.confirm({
        message: "Confirm delete Task?",
        buttons: {
            confirm: {
                label: 'Yes',
                className: 'btn-success'
            },
            cancel: {
                label: 'No',
                className: 'btn-danger'
            }
        },
        callback: function (result) {
            if (result == true)
                window.location = href
            else
                bootbox.alert("Task NOT deleted");
        }
    });
  });
    </script>
    <script type="text/javascript">
                        $(".hh").click(function(e){
                            e.preventDefault();
                            href = this.href;
                            var selector = document.getElementById('imports2');
                            var value = selector[selector.selectedIndex].value;
            if (value == 'today')
            {
                window.location = '{{ url("searchsheettd") }}'
            }
            else if (value == '7day')
            {
              window.location = '{{ url("searchsheetsd") }}'
            }
            else if (value == 'datediff')
            {
            }
            else
                bootbox.alert("Please select an option!");
        
    });
              
    </script>
    <script>
          "use strict";
          function show_selected1() {
              var selector = document.getElementById('imports2');
              var value = selector[selector.selectedIndex].value;
              //document.getElementById('display').innerHTML = value;
              if (value == 'today')
              {
                document.getElementById('display2').style.visibility = 'hidden';
              }
              else if (value == '7day')
              {
                document.getElementById('display2').style.visibility = 'hidden';
              }
              else if (value == 'datediff')
              {
                document.getElementById('display2').style.visibility = "visible";
                document.getElementById("display2").innerHTML = '<form id="ddsubmit" action="{{ URL::to('/searchsheet/') }}" method="post">{{ csrf_field() }}<div class="col-md-3"><input name="from_date" id="from_date" class="form-control" placeholder="From Date" required/></div><div class="col-md-3"><input name="to_date" id="to_date" class="form-control" placeholder="To Date" required/></div><div class="col-md-5"><button class="btn btn-info" />Search Dates</button></div><br /></form><br />  ';
                $('.form-control').datepicker({  
           format: 'yyyy-mm-dd',
           autoclose: true
         });
              }
          }
          </script>
           <script type="text/javascript">  
        $('#from_date').datepicker({  
           format: 'yyyy-mm-dd',
           autoclose: true
         });  
        $('#to_date').datepicker({  
           format: 'yyyy-mm-dd',
           autoclose: true
         });
    </script>
    </table> 
    <div class="text-center">
        {!! $sheet->appends(\Input::except('X-CSRF-TOKEN'))->render() !!}
    </div>
    </table>
    </div>
    </div>
    <button type="submit" onclick="window.location='{{ url("regtime/add") }}'" class="btn btn-primary">Add another Task</button>
    <button type="submit" onclick="window.location='{{ url("home") }}'" class="btn btn-primary">Back</button>
    </div>
    </div>
@endsection

in viewing page source it is showing as follows(Which i don't want to display in URL)

<!-- CSRF Token -->
    <meta name="csrf-token" content="3eeiVKGocLlYTjMwSYFb2ngpblj4rv6E6sapvzz8">

My Url

http://localhost:8000/searchsheet?_token=3eeiVKGocLlYTjMwSYFb2ngpblj4rv6E6sapvzz8&from_date=2017-03-20&to_date=2017-05-05&page=2

27th April, 2017

jhansi started a new conversation How To Get Total Of All Hours Which Is A Column In Table And Download It As Excel(used Maatwebsite) • 4 months ago

exportTb.blade.php

<html>
<head>
<Title> Timesheet Form</Title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
   <table  class="table table-bordered user" >    
   <tr>
            <th>Date </th>
            <th>Project</th>
            <th>Ticket Number</th>
            <th>Ticket Subject</th>
            <th>Hours</th>
        
   </tr>
   @foreach ($sheet as $sheets) 
   <tr>
        <td>{{ $sheets->date }}</td>
                <td>{{ $sheets->Project}}</td>
                <td>{{ $sheets->TicketNumber}}</td>
                <td class="wrapword">{!! clean($sheets->task) !!}</td>
                <td> <?php $date1 = date_create($sheets->time_out);
                             $date2 = date_create($sheets->time_in);
                             $mins = date_diff($date1,$date2);
                             $Hour = $mins->format('%H:%I:%S');
                             echo $Hour;
                             session(['time' => $Hour])?></td>
             
    </tr>
    @endforeach
</table>
<div class="text-center">
</body>
</html>

democontroller

public function downloadExcelS(Request $request, $type)
    {
        
        //$data = sheets::select('date', 'Project', 'TicketNumber', 'task')->get();
        Excel::create('sheets', function($excel){
            $excel->sheet('mySheet', function($sheetss)
            {
                $sheet = DB::table('sheets')->get();
                $lv = $sheetss->loadView('exportTB', array('key'=> 'value'))->with('sheet', $sheet);
            });
        })->download($type);
    }

21st April, 2017

jhansi started a new conversation Can Anyone Help Me How To Calculate Time Differences In Laravel? • 5 months ago

I have difference in time_in and time_out timesheet.blade.php

@extends('layouts.app')

@section('content')
<style>
    .txtarea{
    border: 2px solid; 
    width: 435px;
    resize: vertical;
    overflow: auto;
}

.shorten{
    width: 100px;
};
</style>
<div class="container">
    <div class="row">
    {!! Breadcrumbs::render('regtime/listing.regtime/add') !!}
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Registration</div>   
                <div class="panel-body">

                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/regtime/add') }}">
                        {{ csrf_field() }}

                                             <div class="form-group{{ $errors->has('date') ? ' has-error' : '' }}">
                            <label for="date" class="col-md-4 control-label">Date</label>

                            <div class="col-md-6">
                                <input id="date" type="date" class="shorten" name="date" value="{{ old('date') }}" required>

                                @if ($errors->has('date'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('date') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        
                        <div class="form-group{{ $errors->has('time_in') ? ' has-error' : '' }}">
                            <label for="time_in" class="col-md-4 control-label">Time-in</label>

                            <div class="col-md-6">
                                <input id="time_in" type="Time" class="shorten" name="time_in" value="{{ old('time_in') }}" required>
                                @if ($errors->has('time_in'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('time_in') }}</strong>
                                    </span>
                                @endif
                            </div>
                            </div>
                             <div class="form-group{{ $errors->has('task') ? ' has-error' : '' }}">
                            <label for="task" class="col-md-4 control-label">Task</label>

                            <div class="col-md-6">
                                <textarea id="task" type="text" class="txtarea" name="task" value="{{ old('task') }}" required></textarea>

                                @if ($errors->has('task'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('task') }}</strong>
                                    </span>
                                @endif
                            </div>
                            </div>
                            <div class="form-group{{ $errors->has('time_out') ? ' has-error' : '' }}">
                            <label for="time_out" class="col-md-4 control-label">Time-out</label>

                            <div class="col-md-6">
                                <input id="time_out" type="Time" class="shorten" name="time_out" value="{{ old('time_out') }}" required>

                                @if ($errors->has('time_out'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('time_out') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                       
                         <div class="form-group">
                            <label class="col-md-4 control-label">Captcha</label>

                         <div  class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label"></label>
                         

                            <div class="col-md-6">
                                {!! Form::captcha() !!}

                                @if ($errors->has('g-recaptcha-response'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                            <br/>
                                <button id="submitbtn" type="submit" class="btn btn-primary">
                                    Submit
                                </button>
                                <button type="submit" onclick="window.location='{{ url("home") }}'" class="btn btn-primary">
                                    Back
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    @endsection
    @section('js')

    <script>

        $('#time_in, #time_out').datetimepicker({

        format: 'HH:mm:ss'


        });
    </script>
    <script type="text/javascript">  

        $('#date').datepicker({  
           endDate: new Date(),
           format: 'yyyy-mm-dd',
           autoclose: true
         });  

    </script>
</div>
@endsection

jhansi started a new conversation Can Anyone Guide Me How To Display The Table With This Format In Laravel • 5 months ago

MatchMove Pay Pte Ltd - Timesheet               
Name : Designation - Developer's Full Name              
Period :    March 1 - 31, 2017          
Contract No.                
                
                
Date             Project       Ticket number    Ticket subject (details)                 Hours
03-01-2017  myWallet            3053                   -mywallet dev support         8
04-01-2017     wallet                      540                  my wallet                              8
                       Sub total                                                                                       16
                      Less: Holidays:0 days;Absences:1 days
                       Total                                                                                               16

This is the format which i have to download excel file Can you suggest me how to do it

19th April, 2017

jhansi left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 218: • 5 months ago

@jerrycoe I write create function membercontroller.php

protected function create(array $data)
    {
        return member::create([
            'Name' => $data['name'],
             'Team' => $data['Team'],
              'Vendor' => $data['Vendor'],
              'DateJoined'=>$data['date'],
               'DateCreated'=>$data['date'],
           
        ]);
    }

jhansi left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 218: • 5 months ago

@cviv Can you please mention the lines of code where I committed wrong?

jhansi left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 218: • 5 months ago

@samalapsy

array:7 [▼
  "_token" => "gHfsILfXp6edLTU0Ff8NfxJbWA3mdQ8qpaBxAEcl"
  "Name" => "Janvi"
  "Team" => "IronHide"
  "Vendor" => "Chimera"
  "DateJoined" => "2017-04-19"
  "DateCreated" => "2017-04-19"
  "g-recaptcha-response" => "03AOP2lf5UTfyBWiOafpZBJ4vb2KwEhNtP3dc-GlHZcbTIMLQqZyuQHlhS0Zntzb_yz8iFdfLvdtO5anZzUenWbNuLoSsNO8m7KLzg5Ygfux3FI3rRe1Gv2Xvb7fRNv6guRWmVreW5v7_iGvIogGsHtCgJEQ5an7V-ycHFjaV3cUpAlUOjSeo37r2rJL7IpMnwKd0LN8aHbAAN7IJrB3k1OQakZZ5nFXCiJx89qENTCxaR3dPEHNe9WJ21Yz0va8Geyqbu1Y8AyrSM0lcvd9xG-tWvk4TKpoiSAxUnXNk25Rq3VkcF07pL61OrenJZlwUubCQW7Wn4BAeTj5Ro6Q5I64Tris8A2Cxj4eGsqSu_MSfgXCHL_ulhkAY"
]

It is displaying the data which i have entered but it is not saving in database.

jhansi left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 218: • 5 months ago

@samalapsy If i change both in post then it is not retrieving the data which i am submitting

jhansi started a new conversation MethodNotAllowedHttpException In RouteCollection.php Line 218: • 5 months ago

I don't kow why it is giving error even though I write the code correct web.php

//member routes

Route::get('/member/add', '[email protected]');
Route::get('/member/listing', '[email protected]');
Route::post('/member/add', '[email protected]');

MembersController.php ```

13th April, 2017

jhansi left a reply on Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

@snapey This is my error line of code

<?php echo Form::select('country', $countries, Null, ['class' => 'form-control']); ?>

Countries is a seeded table from which i have to access data to country in vendor table. databaseseeder.php ```

jhansi left a reply on Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

@Snapey I removed this line '$country = $country->prepend('Please Select a Country', '');`

and also used Form::open but still getting the same error

jhansi left a reply on Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

@jenky Then please suggest me how to solve the problem

jhansi left a reply on Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

@Jaytee web.php

//Vendor Routes

Route::get('/vendors/add', function () {
    return view('vendor');
});
Route::get('/vendors/delete/{Vendor_id}','[email protected]');
Route::get('/vendorsedit/{Vendor_id}', '[email protected]');
Route::post('/vendorseditt/{Vendor_id}', '[email protected]');
Route::get('/vendors/listing', '[email protected]');
Route::post('/increment', '[email protected]');
Route::post('/searchvendor','[email protected]');
Route::get('/searchvendortd','[email protected]');
Route::get('/searchvendorsd','[email protected]');

jhansi left a reply on Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

@jaytee I changed the controller as follows:(but still getting the same error )

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Vendor;
use Illuminate\Support\Facades\Redirect;
use Carbon\Carbon;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Seeder;
use App\Country;

class VendorsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function indro()
    {
        $vendors = Vendor::paginate(10); // To use $vendors->links(), you need paginate();
        return  view('indro')->with('vendors', $vendors);
    }

  
    public function hike()
    {
       echo "Your Table is as follows:";
         $vendor = new Vendor;

    $vendor->Vendor = Input::get('Vendor');
    $vendor->Date = Input::get('Date');
   $vendor->country=Input::get('country');
    
    $vendor->save();
        return Redirect::to('vendors/listing');
    }
      /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
      public function create()
    {
         $countries = Country::orderBy('country')->pluck('country', 'country_code');
          $country = $country->prepend('Please Select a Country', '');
        return View::make('vendor', compact(
            'countries'
        ));

    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
          DB::table('vendors')->insert($request->all());
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Request $request, $Vendor_id)
    {
        //
        echo "Your Table is as follows:";
        
        $evendor = Vendor::find($Vendor_id);
        $evendor->Vendor = $request->get('Vendor');
        $evendor->Date = $request->get('Date');
        $evendor->save();
                return Redirect::to('vendors/listing');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function delete($Vendor_id)
    {
        Vendor::find($Vendor_id)->delete();
        return Redirect::to('vendors/listing');

    }

    public function findRecord($Vendor_id)
    {
        $findvendor = Vendor::find($Vendor_id);
            return view('vendoredit')->with('findvendor', $findvendor);
    }

    public function showDateDiff(Request $request)
    {
        $fd = new Vendor;
        $td = new Vendor;
        $fd=$request->input('from_date');
        $td=$request->input('to_date');
        $vendors = Vendor::whereBetween('Date', [$fd, $td])->paginate(10);
        //$fetchs = Team::paginate(10); // To use $teams->links(), you need paginate();
            return view('indro')->with('vendors', $vendors);
    }

    public function today()
    {
        $vendors = Vendor::where('Date', '=', Carbon::today()->toDateString())->paginate(10);
            return view('indro')->with('vendors', $vendors);
    }

    public function sevenday()
    {
        $date = new Carbon;
        $date = Carbon::now()->subWeek();
        $vendors = Vendor::where('Date', '>', $date->toDateString())->paginate(10);
            return view('indro')->with('vendors', $vendors);
    }
}

12th April, 2017

jhansi started a new conversation Undefined Variable: Countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php) • 5 months ago

app/Country.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;


class Country extends Model
{
    
   use Notifiable;
   protected $fillable = [
        'country_name', 'country_code ',
    ];
    Public function vendor()
    {
        return $this-> belongsTo(Vendor::class);
    }
}

app/Vendor.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;


class Vendor extends Model
{
    protected $primaryKey = 'Vendor_id';
    use Notifiable;
    protected $fillable = [
        'Vendor_id', 'Vendor','Date' ,
    ];
    Public function country(){
        return $this->hasOne('App\Country');
    }
}

vendor.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
     {!! Breadcrumbs::render('vendors/listing.vendors/add') !!}
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/increment') }}">
                        {{ csrf_field() }}
                    <div class="form-group{{ $errors->has('Vendor') ? ' has-error' : '' }}">
                        
                            <label for="Vendor" class="col-md-4 control-label">Vendor Name</label>
                            
                     
                            <div class="col-md-6">
                             <input id="Vendor" type="text" class="form-control" name="Vendor" value="{{ old('Vendor') }}" required>
                            
                                @if ($errors->has('Vendor'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Vendor') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('Date') ? ' has-error' : '' }}">
                            <label for="Date" class="col-md-4 control-label">Date</label>

                            <div class="col-md-6">
                                <input id="Date" type="Date" class="date form-control" name="Date" value="{{ old('Date') }}" required>
                                @if ($errors->has('Date'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Date') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                         <?php echo Form::select('country', $countries, Null, ['class' => 'form-control']); ?>
                        

                              <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                    Submit
                                </button>
                                <button type="submit" onclick="window.location='{{ url("home") }}'" class="btn btn-primary">
                                    Back
                                </button>
                            </div>
                        </div>
                   </form>
                </div>
                @endsection
                @section('js')
<script type="text/javascript">  

                                $('.date').datepicker({  

                                format: 'yyyy-mm-dd',
                                autoclose: true

                                });  

                                </script>
            </div>
        </div>
    </div>
</div>
@endsection

vendorcontroller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Vendor;
use Illuminate\Support\Facades\Redirect;
use Carbon\Carbon;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Seeder;
use App\Country;

class VendorsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function indro()
    {
        $vendors = Vendor::paginate(10); // To use $vendors->links(), you need paginate();
        return  view('indro')->with('vendors', $vendors);
    }

  
    public function hike()
    {
       echo "Your Table is as follows:";
         $vendor = new Vendor;

    $vendor->Vendor = Input::get('Vendor');
    $vendor->Date = Input::get('Date');
   $countries = Country::orderBy('countries')->pluck('country_name', 'country_code');
   $countries = $countries->prepend('Please Select a Country', '');

       return view('vendor', compact(
         'countries'
      ))->country();
    
    $vendor->save();
        return Redirect::to('vendors/listing');
    }
      /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
      public function create()
    {
        return View::make('vendor');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
          DB::table('vendors')->insert($request->all());
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Request $request, $Vendor_id)
    {
        //
        echo "Your Table is as follows:";
        
        $evendor = Vendor::find($Vendor_id);
        $evendor->Vendor = $request->get('Vendor');
        $evendor->Date = $request->get('Date');
        $evendor->save();
                return Redirect::to('vendors/listing');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function delete($Vendor_id)
    {
        Vendor::find($Vendor_id)->delete();
        return Redirect::to('vendors/listing');

    }

    public function findRecord($Vendor_id)
    {
        $findvendor = Vendor::find($Vendor_id);
            return view('vendoredit')->with('findvendor', $findvendor);
    }

    public function showDateDiff(Request $request)
    {
        $fd = new Vendor;
        $td = new Vendor;
        $fd=$request->input('from_date');
        $td=$request->input('to_date');
        $vendors = Vendor::whereBetween('Date', [$fd, $td])->paginate(10);
        //$fetchs = Team::paginate(10); // To use $teams->links(), you need paginate();
            return view('indro')->with('vendors', $vendors);
    }

    public function today()
    {
        $vendors = Vendor::where('Date', '=', Carbon::today()->toDateString())->paginate(10);
            return view('indro')->with('vendors', $vendors);
    }

    public function sevenday()
    {
        $date = new Carbon;
        $date = Carbon::now()->subWeek();
        $vendors = Vendor::where('Date', '>', $date->toDateString())->paginate(10);
            return view('indro')->with('vendors', $vendors);
    }
}

two migrations of country

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddCountriesToVendorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('vendors', function (Blueprint $table) {
            $table->string('country')->nullable();
            
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('vendors', function (Blueprint $table) {
            $table->dropColumn('country');

        });
    }
}
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCountriesTabe extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
         Schema::dropIfExists('countries');

        Schema::create('countries', function (Blueprint $table) {
            $table->increments('id');

            $table->string('country_name');
            $table->string('country_code', 3);
           
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
       Schema::drop('countries');

    }
}

databaseseeder.php

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
      

        DB::unprepared(file_get_contents(base_path('database/seeds/sql/countries.sql')));
    }
}

6th April, 2017

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle

return view('path.to.create', compact(
            'countries'

what is this path to create is it refers to vendor.blade file or sql file

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle

// I use the Form facade which will auto create a select list if you pass the $countries collection made in your controller as an arg----->
What does it mean can you please explain it

        <?php echo Form::select('country', $countries, Null, ['class' => 'form-control']); ?>

5th April, 2017

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle I used your step by step procedure as follows: 1st migration table

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddCountriesToVendorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('vendors', function (Blueprint $table) {
            $table->string('country')->nullable();
            
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('vendors', function (Blueprint $table) {
            $table->dropColumn('country');

        });
    }
}

2nd migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCountriesTabe extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
         Schema::dropIfExists('country');

        Schema::create('country', function (Blueprint $table) {
            $table->increments('id');

            $table->string('country_name');
            $table->string('country_code', 3);
           
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
       Schema::drop('country');

    }
}

databaseseed.php

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(UsersTableSeeder::class);
        DB::unprepared(file_get_contents(base_path('database/seeds/sql/country.sql')));
    }
}

country.sql is your seeder file vendor.blade.php ```

Countries
                        <div class="col-md-6">
                            <?php echo Form::select('country', $country, Null, ['class' => 'form-control']); ?>
                @if ($errors->has('country'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('country') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
vendorscontroller.php

public function hike() { echo "Your Table is as follows:"; $vendor = new Vendor;

$vendor->Vendor = Input::get('Vendor');
$vendor->Date = Input::get('Date');
$country = Input::orderBy('country')->pluck('country_name', 'country_code');
    $country = $country->prepend('Please Select a Country', '');

$vendor->save();
    return Redirect::to('vendors/listing');
}
  
but getting the error as follows:

Undefined variable: country (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php)

3rd April, 2017

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle I am getting error as follows:

ErrorException in 25fb94309a75d939c31c9510ae63bb37fc901640.php line 39:
Undefined variable: countries (View: C:\xampp\htdocs\list\resources\views\vendor.blade.php)

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle Any video tutorial so that i can Understand it in a better way

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@jhansi Can we need to keep any route in the files to get the values of countries.Please can you explain me without seeder if possible for you.

31st March, 2017

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

@Screenbeetle can you please tell me where to save this static or related iso code i want only countries names(as a dropdown list) not the codes of countries.I am new to database seeding can you please tell me how to do it briefly.

jhansi left a reply on How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

Can anyone explain me the steps without database seeder?

30th March, 2017

jhansi started a new conversation How To Create A Country Field (with List Of Countries) To Already Migrated Table.can Any Please Guide Me Through Steps • 5 months ago

App/vendor.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;


class Vendor extends Model
{
    protected $primaryKey = 'Vendor_id';
    use Notifiable;
    protected $fillable = [
        'Vendor_id', 'Vendor','Date' ,
    ];
}

vendor.blade.php

@extends('layouts.app')
@section('content')
<div class="container">
    <div class="row">
    
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/increment') }}">
                        {{ csrf_field() }}
                    <div class="form-group{{ $errors->has('Vendor') ? ' has-error' : '' }}">
                        
                            <label for="Vendor" class="col-md-4 control-label">Vendor Name</label>
                            
                     
                            <div class="col-md-6">
                             <input id="Vendor" type="text" class="form-control" name="Vendor" value="{{ old('Vendor') }}" required>
                            
                                @if ($errors->has('Vendor'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Vendor') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('Date') ? ' has-error' : '' }}">
                            <label for="Date" class="col-md-4 control-label">Date</label>

                            <div class="col-md-6">
                                <input id="Date" type="Date" class="date form-control" name="Date" value="{{ old('Date') }}" required>
                               

                                @if ($errors->has('Date'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Date') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                              <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                    Submit
                                </button>
                                <button type="submit" onclick="window.location='{{ url("home") }}'" class="btn btn-primary">
                                    Back
                                </button>
                            </div>
                        </div>
                   </form>
                </div>
                @endsection
                @section('js')

            </div>
        </div>
    </div>
</div>
@endsection

migration table

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateVendorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('vendors', function (Blueprint $table) {
            $table->increments('Vendor_id');
            $table->string('Vendor');    
            $table->date('Date');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vendors');
    }
}

29th March, 2017

jhansi left a reply on Can Anyone Tell Me How To Write Routes/breadcrumbs.php For My File With Output It In My Blade Files. • 5 months ago

@topvillas i tried but it is not working it is giving error as unknown route home even though it is there.

jhansi started a new conversation Can Anyone Tell Me How To Write Routes/breadcrumbs.php For My File With Output It In My Blade Files. • 5 months ago

I used the package davejamesmiller/laravel-breadcrumbs my route file (web.php)

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

//Route group for simple authentication
Route::group(['middleware' => 'authenticated'], function(){

//User Routes
Route::get('/home', '[email protected]');
Route::get('site-register', 'Auth\[email protected]');
Route::post('site-register', 'Auth\[email protected]');
Route::get('/user','[email protected]');
Route::get('/reg', '[email protected]');
Route::post('/reg', '[email protected]');


//Tasks Routes
Route::get('/regtime/delete/{timesheet_id}','[email protected]');
Route::get('/regtime/edit/{timesheet_id}','[email protected]');
Route::get('/timesheetedit/{timesheet_id}', '[email protected]');
Route::post('/timesheeteditt/{timesheet_id}', '[email protected]');
Route::get('/regtime/add', function () {
    return view('regtime');
});
Route::get('/regtime/listing', '[email protected]');
Route::post('/regtime/add', '[email protected]');


//Excel Import / Export Routes
//Import / Export for Users
Route::get('importExport', '[email protected]');
Route::get('downloadExcel/{type}', '[email protected]');
Route::post('importExcel', '[email protected]');

//Import / Export for Teams
Route::get('importExportT', '[email protected]');
Route::post('importExcelT', '[email protected]');
Route::get('downloadExcelT/{type}', '[email protected]');

//Import / Export for Vendors
Route::get('importExportV', '[email protected]');
Route::post('importExcelV', '[email protected]');
Route::get('downloadExcelV/{type}', '[email protected]');

//export the timesheet table
Route::get('importExportS', '[email protected]');
Route::post('importExcelS', '[email protected]');
Route::get('downloadExcelS/{type}', '[email protected]');


//Team Routes
Route::get('/teams/add', function () {
    return view('team');
});
Route::get('/teams/delete/{Team_id}','[email protected]');
Route::get('/teamsedit/{Team_id}', '[email protected]');
Route::post('/teamseditt/{Team_id}', '[email protected]');
Route::get('/teams/listing', '[email protected]');
Route::post('/insert', '[email protected]');

//Vendor Routes

Route::get('/vendors/add', function () {
    return view('vendor');
});
Route::get('/vendors/delete/{Vendor_id}','[email protected]');
Route::get('/vendorsedit/{Vendor_id}', '[email protected]');
Route::post('/vendorseditt/{Vendor_id}', '[email protected]');
Route::get('/vendors/listing', '[email protected]');
Route::post('/increment', '[email protected]');

});

24th March, 2017

jhansi left a reply on How To Solve CURL Error • 5 months ago

I am using windows 8.1 .my code is as follows: registercontroller.php

<?php

namespace App\Http\Controllers\Auth;
use Illuminate\Support\Facades\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Http\Request;
use App\Team;
use App\Vendor;

class RegisterController extends Controller
{
   

    use RegistersUsers;

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'Team'=>'max:20',
            'Vendor'=>'max:40',
            'password' => 'required|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
             'Team' => $data['Team'],
              'Vendor' => $data['Vendor'],
            'password' => bcrypt($data['password']),
        ]);
    }
    
    public function siteRegister()
    {
        return view('register');
    }
    public function siteRegisterPost(Request $request)
    {
      // echo '<pre>################';
       // print_r($request->all());
 $this->validate($request, [
            'name' => 'required',
            'email' => 'required|email',
            'password' => 'required|same:password_confirmation',
            'password_confirmation' => 'required',
            'g-recaptcha-response' => 'required|captcha',
        ]);
        // Auth::login($user);
        return Redirect::to('home');
       // print('done');
        // $selectData = $request->input('Team');
        //  $selectData = $request->input('Vendor');


    }

 public function showregistrationform()
{
   
     $teams = Team::all(['Team_id','Team']);
  
     $vendors = Vendor::all(['Vendor_id','Vendor']);
    //echo '<pre>'.print_r($teams,true).'</pre>';

     
    return view('auth.register', [ 'teams' =>$teams,'vendors' => $vendors]);
}

}

register.blade.php


@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Register</div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/site-register') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label for="name" class="col-md-4 control-label">Name</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>

                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('Team') ? ' has-error' : '' }}">
                        
                            <label for="Team" class="col-md-4 control-label">Team</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Team" class="form control">
                  
                  @foreach($teams as $team)
            <option value="{{ $team->Team_id }}" <?php echo ($team->Team_id==2)? 'selected':'';?> >{{ $team->Team }}</option>    
@endforeach
                               
                                 


                            </select>
                                @if ($errors->has('Team'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Team') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                         <div class="form-group{{ $errors->has('Vendor') ? ' has-error' : '' }}">
                        
                            <label for="Vendor" class="col-md-4 control-label">Vendor</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Vendor" class="form control">
                             @foreach($vendors as $vendor)
            <option value="{{ $vendor->Vendor_id }}" <?php echo ($vendor->Vendor_id==2)? 'selected':'';?> >{{ $vendor->Vendor }}</option>    
@endforeach
                    

                            </select>
                                @if ($errors->has('Vendor'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Vendor') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>


                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">Password</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
                            </div>
                        </div>
                        <div class="form-group">

                            <label class="col-md-4 control-label">Captcha</label>
                            <div  class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
                            

                            <div class="col-md-6">
                             

                                @if ($errors->has('g-recaptcha-response'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Register
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

web.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();
Route::get('/user','[email protected]');
//Route::group(['middleware' => 'authenticated'], function(){
    //user routes

Route::get('/home', '[email protected]');


Route::get('site-register', 'Auth\[email protected]');
Route::post('site-register', 'Auth\[email protected]');


//task routes
Route::get('/regtime/add', function () {
    return view('regtime');
});

Route::get('/regtime/listing', '[email protected]');

Route::post('/regtime/add', '[email protected]');
Route::get('/regtime/delete{timesheet_id}','[email protected]');
Route::get('/regtime/edit{timesheet_id}','[email protected]');
Route::get('/timesheetedit/{timesheet_id}', '[email protected]');
Route::post('/timesheeteditt/{timesheet_id}', '[email protected]');
//import/export routes

Route::get('importExport', '[email protected]');
Route::get('downloadExcel/{type}', '[email protected]');
Route::post('importExcel', '[email protected]');

Route::get('/reg', '[email protected]');
Route::post('/reg', '[email protected]');
//Team routes

Route::get('/teams/add', function () {
    return view('team');
});
Route::get('/teams/listing', '[email protected]');

Route::post('/insert', '[email protected]');
//vendor routes

Route::get('/vendors/add', function () {
    return view('vendor');
});

Route::get('/vendors/listing', '[email protected]');

Route::post('/increment', '[email protected]');

//});

}

22nd March, 2017

jhansi left a reply on How To Solve CURL Error • 6 months ago

@bobbybouwmann still getting the same error after restarting the xampp server

jhansi started a new conversation How To Solve CURL Error • 6 months ago

cURL error 28: Resolving timed out after 2625 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

20th March, 2017

17th March, 2017

jhansi left a reply on Illegal String Offset 'name'.how To Solve This Error Can Anyone Please Tell Me • 6 months ago

@SaeedPrez please explain me via example so that i can understand it clearly

jhansi left a reply on Illegal String Offset 'name'.how To Solve This Error Can Anyone Please Tell Me • 6 months ago

No it was not solved.same error occuring

jhansi left a reply on Illegal String Offset 'name'.how To Solve This Error Can Anyone Please Tell Me • 6 months ago

Yes,but it is the way to insert data (import) to my users table

jhansi started a new conversation Illegal String Offset 'name'.how To Solve This Error Can Anyone Please Tell Me • 6 months ago

http://www.awesomescreenshot.com/showImage?img_id=2303478 You can see error by going to above url. Democontroller.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\User;
use Excel;

class DemoController extends Controller
{
    public function importExport()
    {
        return view('importExport');
    }
    public function downloadExcel(Request $request, $type)
    {
        $data = User::get()->toArray();
        return Excel::create('users', function($excel) use ($data) {
            $excel->sheet('mySheet', function($sheet) use ($data)
            {
                $sheet->fromArray($data);
            });
        })->download($type);
    }

    /**
     * Import file into database Code
     *
     * @var array
     */
    public function importExcel(Request $request)
    {

        if($request->hasFile('import_file')){
            $path = $request->file('import_file')->getRealPath();

            $data = Excel::load($path, function($reader) {})->get();

            if(!empty($data) && $data->count()){

                foreach ($data->toArray() as $key => $value) {
                    if(!empty($value)){
                        foreach ($value as $v) {        
                            $insert[] = ['name' => $v['name'], 'email' => $v['email'],'Team' => $v['Team'],'Vendor' => $v['Vendor'],'password'=>$v['password'];
                        }
                    }
                }

                
                if(!empty($insert)){
                    User::insert($insert);
                    return back()->with('success','Insert Record successfully.');
                }

            }

        }

        return back()->with('error','Please Check your file, Something is wrong there.');
    }

}

web.php

ute::get('importExport', '[email protected]');
Route::get('downloadExcel/{type}', '[email protected]');
Route::post('importExcel', '[email protected]');

importExport.blade.php

<html lang="en">
<head>
    <title>Import - Export Laravel 5.3</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
</head>

<body>
<br/>
<br/>
    <div class="container">     
        <div class="panel panel-primary">
          <div class="panel-heading">
            <h3 class="panel-title" style="padding:12px 0px;font-size:25px;"><strong>Laravel 5.3 - import export csv or excel file into database example</strong></h3>
          </div>
          <div class="panel-body">

                @if ($message = Session::get('success'))
                    <div class="alert alert-success" role="alert">
                        {{ Session::get('success') }}
                    </div>
                @endif

                @if ($message = Session::get('error'))
                    <div class="alert alert-danger" role="alert">
                        {{ Session::get('error') }}
                    </div>
                @endif

                <h3>Import File Form:</h3>
                <form style="border: 4px solid #a1a1a1;margin-top: 15px;padding: 20px;" action="{{ URL::to('importExcel') }}" class="form-horizontal" method="post" enctype="multipart/form-data">

                    <input type="file" name="import_file" />
                    {{ csrf_field() }}
                    <br/>

                    <button class="btn btn-primary">Import CSV or Excel File</button>

                </form>
                <br/>

                
                <h3>Import File From Database:</h3>
                <div style="border: 4px solid #a1a1a1;margin-top: 15px;padding: 20px;">         
                    <a href="{{ url('downloadExcel/xls') }}"><button class="btn btn-success btn-lg">Download Excel xls</button></a>
                    <a href="{{ url('downloadExcel/xlsx') }}"><button class="btn btn-success btn-lg">Download Excel xlsx</button></a>
                    <a href="{{ url('downloadExcel/csv') }}"><button class="btn btn-success btn-lg">Download CSV</button></a>
                </div>

          </div>
        </div>
    </div>

</body>

</html>

16th March, 2017

jhansi left a reply on My Page Is Registering Without Google Recaptcha .How To Validate It Can Anyone Please Tell Me? • 6 months ago

By using xampp server in local browser .My problem is without taking any google recaptcha my page is going to login page.can you please help me regarding that?

jhansi left a reply on My Page Is Registering Without Google Recaptcha .How To Validate It Can Anyone Please Tell Me? • 6 months ago

register.blade.php


@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Register</div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label for="name" class="col-md-4 control-label">Name</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>

                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('Team') ? ' has-error' : '' }}">
                        
                            <label for="Team" class="col-md-4 control-label">Team</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Team" class="form control">
                  
                  @foreach($teams as $team)
            <option value="{{ $team->Team }}" <?php echo ($team->Team_id==2)? 'selected':'';?>>{{ $team->Team }}</option>  
            
                 @endforeach
                               
                                 


                            </select>
                                @if ($errors->has('Team'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Team') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                         <div class="form-group{{ $errors->has('Vendor') ? ' has-error' : '' }}">
                        
                            <label for="Vendor" class="col-md-4 control-label">Vendor</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Vendor" class="form control">
                             @foreach($vendors as $vendor)
            <option value="{{ $vendor->Vendor }}" <?php echo ($vendor->Vendor_id==2)? 'selected':'';?> >{{ $vendor->Vendor }}</option>    
@endforeach
                    

                            </select>
                                @if ($errors->has('Vendor'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Vendor') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>


                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">Password</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label">Captcha</label>

                            <div class="col-md-6">
                                {!! app('captcha')->display() !!}

                                @if ($errors->has('g-recaptcha-response'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Register
                                </button>
                            </div>
                        </div>
                    </form>
                    <script src="https://www.google.com/reCAPTCHA/api.js">
    </script>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Register</div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label for="name" class="col-md-4 control-label">Name</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>

                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('Team') ? ' has-error' : '' }}">
                        
                            <label for="Team" class="col-md-4 control-label">Team</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Team" class="form control">
                  
                  @foreach($teams as $team)
            <option value="{{ $team->Team }}" <?php echo ($team->Team_id==2)? 'selected':'';?>>{{ $team->Team }}</option>  
            
                 @endforeach
                               
                                 


                            </select>
                                @if ($errors->has('Team'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Team') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                         <div class="form-group{{ $errors->has('Vendor') ? ' has-error' : '' }}">
                        
                            <label for="Vendor" class="col-md-4 control-label">Vendor</label>
                            
                            
                            <div class="col-md-6">
                            <select name="Vendor" class="form control">
                             @foreach($vendors as $vendor)
            <option value="{{ $vendor->Vendor }}" <?php echo ($vendor->Vendor_id==2)? 'selected':'';?> >{{ $vendor->Vendor }}</option>    
@endforeach
                    

                            </select>
                                @if ($errors->has('Vendor'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('Vendor') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>


                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">Password</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('g-recaptcha-response') ? ' has-error' : '' }}">
                            <label class="col-md-4 control-label">Captcha</label>

                            <div class="col-md-6">
                                {!! app('captcha')->display() !!}

                                @if ($errors->has('g-recaptcha-response'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Register
                                </button>
                            </div>
                        </div>
                    </form>
                    <script src="https://www.google.com/reCAPTCHA/api.js">
    </script>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

registercontroller.php

<?php

namespace App\Http\Controllers\Auth;
use Illuminate\Support\Facades\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
use App\Team;
use App\Vendor;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'Team'=>'max:20',
            'Vendor'=>'max:40',
            'password' => 'required|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
             'Team' => $data['Team'],
              'Vendor' => $data['Vendor'],
            'password' => bcrypt($data['password']),
        ]);
    }
    public function siteRegister()
    {
        return view('siteRegister');
    }

    public function siteRegisterPost(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'email' => 'required|email',
            'password' => 'required|same:password_confirmation',
            'password_confirmation' => 'required',
            'g-recaptcha-response' => 'required|captcha',
        ]);
        print('done');
         $selectData = $request->input('Team');
          $selectData = $request->input('Vendor');


    }
 public function showregistrationform()
{
   
     $teams = Team::all(['Team_id','Team']);
  
     $vendors = Vendor::all(['Vendor_id','Vendor']);
    //echo '<pre>'.print_r($teams,true).'</pre>';

     
    return view('auth.register', [ 'teams' =>$teams,'vendors' => $vendors]);
}

}

web.php

    return view('welcome');
});

Auth::routes();

Route::get('/home', '[email protected]');
Route::get('site-register', 'Auth\[email protected]');
Route::post('site-register', 'Auth\[email protected]');
Route::get('/user','[email protected]');



Route::get('/Team', function () {
    return view('team');
});
Route::get('/teams', '[email protected]');

Route::post('/insert', '[email protected]');

Route::get('/Vendor', function () {
    return view('vendor');
});

Route::get('/vendors', '[email protected]');

Route::post('/increment', '[email protected]');

jhansi started a new conversation My Page Is Registering Without Google Recaptcha .How To Validate It Can Anyone Please Tell Me? • 6 months ago

Please upgrade to a supported browser to get a reCAPTCHA challenge.

Alternatively if you think you are getting this page in error, please check your internet connection and reload.

Why is this happening to me?

This is appearing on the page.By using this site I used google reCaptcha http://itsolutionstuff.com/post/laravel-5-google-recaptcha-code-and-validation-example-using-anhskohbo-no-captcha-packageexample.html

6th March, 2017

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

@Yama Can you please just tell me an example so that I can it clearly

5th March, 2017

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

Can anyone tell me how to get the selected value from team table to users table using id,Team_id,name?

3rd March, 2017

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

I wrote the code as follows but it is still giving the same error as null

<select name="Admin">
<option value="">Select Team</option>

<option value="Admin  @if(old('Admin',$teams->Team_id) == "Admin") selected @endif >Admin</option>

<option value="Developer"  @if(old('Admin',$teams->Team_id) == "Developer") selected @endif >Developer</option>
</select>

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

@christianus But i need to get the values from the table team instead of writing it manually.

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

it is giving null value

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

This my change in register.blade.php

<select class="form-control" name="Team_id">

    @if ($Teams->count())

        @foreach($Teams as $Team)
            <option value="{{ $Team->id }}" {{ $selectedTeam== $Team->id ? 'selected="selected"' : '' }}>{{ $Team->name }}</option>    
@endforeach
    @endif

</select>

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

Then it is giving error as:

Undefined variable: Teams (View: C:\xampp\htdocs\list\resources\views\auth\register.blade.php)

2nd March, 2017

jhansi left a reply on Please Tell Me How To Select DropDown Option Selected In Laravel • 6 months ago

@cviv In controller i used it

public function index()
{
    $Teams = Team::all();
    $selectedTeam = User::first()->Team_id;

    return view('auth.register', compact('Teams', 'selectedTeam');
}
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.