mardi 3 décembre 2019

in laravel how to search and display student data in view by using 2 input filed "id" and and "date of join"

Present i created single input filed "id" if enter valid id it showing student ( name, email, Id). this is working Perfectly.

now i what to add one more input filed "date of join"

in this function i what to check input "id" and "date of join", is mach then show student data in view, or else it show ("data not found") message

MY VIEW

<form action="/search" method="POST" role="search">
    
    <div class="input-group">
        <input type="text" class="form-control" name="id"
            placeholder="Search users">

             <span class="input-group-btn">
            <button type="submit" class="btn btn-default">
                <span class="glyphicon glyphicon-search"></span>
            </button>
        </span>
    </div>

</form>

<div class="container">
    @if(isset($details))
        <p> The Search results for your query <b>  </b> are :</p>
    <h2>Sample User details</h2>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>id</th>
                    <th>Photo</th>
                    <th>certificate_approval</th>
            </tr>
        </thead>
        <tbody>
            @foreach($details as $user)
            <tr>
                <td></td>
                <td></td>
       <div class="card-body">
    <img src="STUDENT_DATA/STUDENT_PHOTO/" class="img-circle" width="90" />


                                </div>


                                    <td></td>
                                     <td></td>
            </tr>
            @endforeach
        </tbody>
    </table>
    @elseif(isset($message))
    <p></p>
    @endif
</div>

MY ROUTE

 use App\Student;
 use Illuminate\Support\Facades\Input;
Route::any( '/search', function(){
    $id = Input::get( 'id' );
    if($id != ""){

$user = Student::where( 'student_registration_id', 'LIKE', '%' . $id . '%' )->get();

     if (count ( $user ) > 0)
     return view( 'my-search' )->withDetails( $user )->withQuery($id);
}

     return view ( 'my-search' )->withMessage ( "No Details found!" );
} );

MY MODEL

<?php

namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Model;

class Student extends Model
{
    protected $table = 'student_lists';


    protected $fillable = ['student_name', 'student_registration_id', 'date_of_join', 'student_phone_no', 'student_photo', ];





}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire