<?php namespace App\Http\Controllers;?>
<!DOCTYPE html>
<html>

<head>

    <title>Useful Link| Admin |  Samuhik Saving & Co-Operative Society Ltd. </title>
    @include('Admin.Parts.MetaCSS')
</head>

<body>

<!--====================================================
                     MAIN NAVBAR
======================================================-->
    @include('Admin.Parts.TopHeader')

<!--====================================================
                    PAGE CONTENT
======================================================-->
    <div class="page-content d-flex align-items-stretch">

        <!--***** SIDE NAVBAR *****-->
        @include('Admin.Parts.LeftNav')

        <div class="content-inner form-cont">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-6 col-lg-6">
                           @if (session('info'))
                           <div class="alert alert-success" style="text-transform: capitalize;">
                              {{session('info')}}
                           </div>
                           @endif
                           @php
                               $link=session('avisd');
                           @endphp
                           @if ($errors->any())
                           <div class="alert alert-danger">
                              <ul>
                                 @foreach ($errors->all() as $error)
                                 <li>{{ $error }}</li>
                                 @endforeach
                              </ul>
                           </div>
                           @endif
                        </div>
                     </div>
                    <div class="card form" id="form1">
                        <div class="card-header">
                            <h3>Add Useful Link</h3>
                        </div>
                        <br>
                        @if(!$link)
                        <form action="admin_useful_link" method="post" enctype="multipart/form-data">
                            @else
                            <form action="{{url('admin_useful_link/update',array($link->id))}}" method="post" enctype="multipart/form-data">
                            @endif
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="title">Title<i style="color: red">*</i></label>
                                        <input type="text" class="form-control" id="title" placeholder="Enter Name" name="title" value="<?php if($link) {echo $link->title;}?>" required>
                                        
                                    </div>
                                    <div class="form-group">
                                        <label for="title">Link<i style="color: red">*</i></label>
                                        <input type="text" class="form-control" id="title" placeholder="Enter link" name="links" value="<?php if($link) {echo $link->links;}?>" required>
                                        
                                    </div>
                                     <div class="form-group">
                                        <label for="exampleInputFile">Logo Image<i style="color: red">*</i> <i style="margin-left: 20px; font-size: 10px;">single image</i></label>
                                        @if(!$link)
                                        <input type="file" class="form-control-file" id="exampleInputFile" name="image" required>
                                        @else
                                        <input type="file" class="form-control-file" id="exampleInputFile" name="image" >
                                        <br>
                                        <div class="form-group">
                                            <img src="img/UsefulLink/{{$link->token}}.jpg?t={{rand()}}" width="250" height="150">
                                        </div>
                                        @endif
                                       
                                    </div>
                                  
                                    
                                </div>
                                
                            </div>
                            <input type="hidden" name="_token" value="{{csrf_token()}}">
                            
                            <button type="reset" class="btn btn-general btn-white">Cancel</button>
                            <button type="submit" class="btn btn-general btn-blue mr-2"><?php if($link){echo "Update";}else {echo "Save";}?></button>
                        </form>
                    </div>

       <div class="card form" id="form1">           
        <div class="row">
          <div class="col-md-12">
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Data Table</h3>
              </div>
             <!-- /.box-header -->
             <div class="box-body" >
              <table id="example2" class="table table-bordered table-hover">
                <thead>
                  <tr>
                  <th width="5%">SN</th>
                
                  <th width="30%">Title</th> 
                  <th width="45%">Link</th>            
                
                
                  
                  <th width="20%">Action</th>
                </tr>
                </thead>
                <tbody>
     
                  <tbody>
                  
                    <?php
                    echo AdminlogController::table_generator('useful_links',array('title', 'links'), 'admin_useful_link','Useful Link');?>
  
           
                </tbody>
               
              </table>
            </div>
            <!-- /.box-body -->
            </div>
          </div>
        </div>
    </div>

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

@include('Admin.Parts.Js')
</body>

</ht