lundi 25 avril 2016

Else Part is not executing even when condition is false Laravel 5.2

I am working on a Web application where i am searching for student result.By entering student roll no i am getting his data from Database.I have Student Model and Students controller , i am getting input from form and field name = keyword . I am comparing $rollno and the keyword it is working perfect but the else part just executes when i enter roll no 0 , without zero whatever i enter it show me the empty view and else part is not executing.

Search function is in Students Controller

public function search()
        {
            $keyword = Input::get('keyword');
            $rollno = Student::find($keyword);
            if($rollno = $keyword){
                return View::make('results.single')
                ->with('search',Student::where('rollno',$keyword)
                ->get())->with('keyword',$keyword);
            }else{
                return 'Nothing Found';
            }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire