Kanchan186
1 week ago

ErrorException (E_ERROR) Undefined variable: department (View: C:\xampp\htdocs\partsanalysis\resources\views\backend\employee_zone_mapping\editempzone.blade.php)

Posted 1 week ago by Kanchan186

editempzone.blade.php

<form method="post" action="{{url('/')}}/employee_zone_mapping/{{$empzonemapping->empzone_id}}">
                                {{method_field('PATCH')}}{{csrf_field()}}

                                    <div class="form-group">
                                        <h5>Department<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                          <select class="form-control" name="department_id"  required>  
                                        
                                            @foreach($department as $br)
                                            
                                                @if($br->department_id == $empzonemapping->department_id )
                                                     <option value="{{$br->department_id}}" selected >{{$br->department_name}}</option>
                                                @else
                                                     <option value="{{$br->department_id}}">{{$br->department_name}}</option>
                                                @endif

                                            @endforeach
                                        </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <h5>Designation<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                          <select class="form-control" name="designation_id"  required>  
                                    
                                        @foreach($designation as $br)
                                            
                                                @if($br->designation_id == $empzonemapping->designation_id )
                                                     <option value="{{$br->designation_id}}" selected >{{$br->designation_name}}</option>
                                                @else
                                                     <option value="{{$br->designation_id}}">{{$br->designation_name}}</option>
                                                @endif

                                            @endforeach
                                        </select>

                                        </div>
                                    </div>

                                
                                <div class="form-group">
                                        <h5>Employee Name <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                             <select class="form-control" name="emp_id" required>
                                                <option>--Select Employee--</option>
                                            @foreach($employee as $br)
                                            <option value="{{$br->emp_id}}">{{$br->emp_fname}}  {{$br->emp_lname}}</option>
                                            @endforeach
                                        </select>

                                        </div>
                                       
                                    </div>




                                    <div class="form-group">
                                        <label for="inputPassword3" class="col-sm-3 control-label">Zone Name 
                                        <span class="required"> * </span></label>
                                        <div class="col-sm-8">
                                        <select class="form-control" name="zone_id" required>
                                            @foreach($zone as $br)
                                            
                                                @if($br->zone_id == $empzonemapping->zone_id )
                                                     <option value="{{$br->zone_id}}" selected >{{$br->zone_name}}</option>
                                                @else
                                                     <option value="{{$br->zone_id}}">{{$br->zone_name}}</option>
                                                @endif

                                            @endforeach
                                        </select>
                                        </div>
                                    </div> 

                                            <div class="box-footer">
                                    <div class="col-sm-3 control-label"></div>
                                        <div class="col-sm-8">
                                        <button type="submit" class="btn btn-primary">Submit</button>
                                        &nbsp;&nbsp;
                                        <button class="btn btn-default" type="reset">Reset</button>
                                        </div>
                                    </div><!-- /.box-footer -->
                                </form>

empzoneController.php

public function edit(EmpzoneMapping $empzone_id)
  {
    $empzonemapping=EmpzoneMapping::where('empzone_mappings.empzone_id',$empzone_id->empzone_id)

         ->join('departments','empzone_mappings.department_id','=','departments.department_id')
         ->join('designations','empzone_mappings.designation_id','=','designations.designation_id')
         ->join('employees','empzone_mappings.emp_id','=','employees.emp_id')
         ->join('zones','empzone_mappings.zone_id','=','zones.zone_id')

         ->select('zone_name','emp_fname','emp_lname','department_name','designation_name','empzone_mappings.*')->first();


   // $department=Department::get();
    $designation=designation::get();
    $zone=Zone::get();
    $employee=Employee::get();
    //$empzonemapping=EmpzoneMapping::get();
   


    return view('backend.employee_zone_mapping.editempzone',compact('empzonemapping','employee','designation','zone'));
  }

  public function update(Request $req,EmpzoneMapping $empzonemapping)
  {

    $empzonemapping->update($req->all());

   return redirect('employee_zone_mapping/view');

  }

Please sign in or create an account to participate in this conversation.