2016-07-13 2 views
0

Ich habe 2-Funktionen in einem ControllerLaravel passieren variabel von 1-Funktion in der Steuerung auf eine andere

Dies ist die Funktion get

public function getAllDept($allDEPT2) 
{ 
    $allDEPT = Facultyform::where('Home_Department_Desc', '=', $allDEPT2)->paginate(1); 

$allDEPTs = View::make('faculty/dept', compact('allDEPT','certifications','certifications1','advisment','facultydata','facultydata1','facultydegree','facultydegree1','commembership', 'commembership1','otherpro','otherpro1','priorteaching','priorteaching1','publication','publication1','professioncourse','professioncourse1','support','support1','otherschool','otherschool1')); 



    return $allDEPTs; 
} 

Dies ist der Post-Funktion

public function getAllDept2() 
{ 
    if (Session::token() !== Input::get('_token')) { 
      return Response::json(array(
       'msg' => 'Unauthorized attempt to create setting' 
      )); 
     } 

     $fId = Input::get('faculty_id'); 

     $faculty = Facultyform::where('File_Number', '=', $fId) 
     ->get(); 
     if($faculty[0]['isChair'] == 'Y'){ 
    $allDEPT2 = $faculty[0]['Home_Department_Desc']; 

    $allDEPT = Facultyform::where('Home_Department_Desc', '=', $allDEPT2)->paginate(1); 
    $this->getAllDept($allDEPT2); 

     $allDEPTs = View::make('faculty/dept', compact('allDEPT','certifications','certifications1','advisment','facultydata','facultydata1','facultydegree','facultydegree1','commembership', 'commembership1','otherpro','otherpro1','priorteaching','priorteaching1','publication','publication1','professioncourse','professioncourse1','support','support1','otherschool','otherschool1')); 



    return $allDEPTs; 
    } 

I haben beide Routen erstellt

Route::get('faculty/dept',array(
    'uses' => '[email protected]' 
)); 

Route::post('faculty/dept', array(
    'as' => 'faculty/dept', 
    'uses' => '[email protected]' 
)); 

Wenn der Endbenutzer die Fakultät/getDept verwendet und die ID setzt, zeigt es das erste Element in der Liste unter Verwendung der Ansicht, aber wenn ich auf die nächste Seite klicke, bekomme ich den folgenden Fehler: Fehlendes Argument 1 für FacultyController :: getAllDept () Wenn ich eine Abteilung fest kodiere, funktioniert die Paginierung aber nur für die hart kodierte Abteilung.

Ich versuchte $ this> getALLDept ($ allDEPT2); Ich habe versucht, eine Sitzung der Variablen Ich habe versucht, die Variable global gibt es etwas, was ich in der Steuerung tun können, um die Variable von einer Funktion auf die andere Funktion übergeben oder mache ich dies in der Route?

Dies ist, was die eine der Funktionen aussehen

 public function getFacultyId() { 
     //check if its our form 
     if (Session::token() !== Input::get('_token')) { 
      return Response::json(array(
       'msg' => 'Unauthorized attempt to create setting' 
      )); 
     } 
     //check if its our form 
     if (Session::token() !== Input::get('_token')) { 
      return Response::json(array(
       'msg' => 'Unauthorized attempt to create setting' 
      )); 
     } 

     $fId = Input::get('faculty_id'); 

     $faculty = Facultyform::where('File_Number', '=', $fId) 
     ->get(); 
     $lastNames = $faculty[0]['Last_Name']; 
     $firstNames = $faculty[0]['First_Name']; 

      $certCount = Certifications::where('Last_Name','=',$lastNames) 
     ->where('First_Name','=',$firstNames) 

     ->count(); 
     if ($certCount < 1) 
     { 
     $certifications1 = "N/A"; 
     } 
     else 
     { 
     $certifications1 = " "; 
     } 

     $certifications = Certifications::where('Last_Name','=',$lastNames) 
     ->where('First_Name','=',$firstNames) 

     ->get(); 

     $advisment = Advisment::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 

     $fsCount = $facultydata = Facultydata::where('Last_Name','=',$lastNames)    
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($fsCount < 1) 
     { 
     $facultydata1 = "N/A"; 
     } 
     else 
     { 
     $facultydata1 = " "; 
     } 
     $facultydata = Facultydata::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $eduCount = Facultydegree::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($eduCount < 1) 
     { 
     $facultydegree1 = "N/A"; 
     } 
     else 
     { 
     $facultydegree1 = " "; 
     } 
     $facultydegree = Facultydegree::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $comCount = Commembership::where('Last_Name','=',$lastNames)    
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($comCount < 1) 
     { 
     $commembership1 = "N/A"; 
     } 
     else 
     { 
     $commembership1 = " "; 
     } 

     $commembership = Commembership::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $otherCount = OtherPro::where('Last_Name', '=', $lastNames) 
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($otherCount < 1) 
     { 
     $otherpro1 = "N/A"; 
     } 
     else 
     { 
     $otherpro1 = " "; 
     } 
     $otherpro = OtherPro::where('Last_Name', '=', $lastNames) 
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $ptCount = PriorTeaching::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($ptCount < 1) 
     { 
     $priorteaching1 = "N/A"; 
     } 
     else 
     { 
     $priorteaching1 = " "; 
     } 
     $priorteaching = PriorTeaching::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $pubCount = Publications::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($pubCount < 1) 
     { 
     $publication1 = "N/A"; 
     } 
     else 
     { 
     $publication1 = " "; 
     } 
     $publication = Publications::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 
     $pcCount = ProfessionCourse::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
      if ($pcCount < 1) 
     { 
     $professioncourse1 = "N/A"; 
     } 
     else 
     { 
     $professioncourse1 = " "; 
     } 
     $professioncourse = ProfessionCourse::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 
     $supportCount = Support::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
      if ($supportCount < 1) 
     { 
     $support1 = "N/A"; 
     } 
     else 
     { 
     $support1 = " "; 
     } 
     $support = Support::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 

     $osCount = OtherSchool::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->count(); 
     if ($osCount < 1) 
     { 
     $otherschool1 = "N/A"; 
     } 
     else 
     { 
     $otherschool1 = " "; 
     } 
     $otherschool = OtherSchool::where('Last_Name','=',$lastNames)   
     ->where('First_Name','=',$firstNames) 
     ->get(); 
$allviews = View::make('faculty.faculty', compact('faculty','certifications','certifications1','advisment','facultydata','facultydata1','facultydegree','facultydegree1','commembership', 'commembership1','otherpro','otherpro1','priorteaching','priorteaching1','publication','publication1','professioncourse','professioncourse1','support','support1','otherschool','otherschool1')); 

Ich machte eine für jede Abteilung, die es angefordert. Ich hatte 3 (alle, finanziell und akademisch) bis jetzt, dann hat es mich getroffen, um einen zu machen, dass jeder Abteilungsstuhl nur ihre Abteilungsinfo sehen kann, indem er ihre Beglaubigungsdaten eingibt. Die Sicherheit funktioniert wollen einfach nur ihre Abteilung in die andere Funktion zu übergeben

ich eine Variable in der Steuerung gemacht genannt Abteilung

public function getAllDept($department){ 

$department = Facultyform::where('Home_Department_Desc', '=',$department)->get(); 
echo($department[0]['Home_Department_Desc']); 
$allDEPT = Facultyform::where('Home_Department_Desc', '=',$department[0]['Home_Department_Desc'])->paginate(1); 
$lastNames = $allDEPT[0]['Last_Name']; 
$firstNames = $allDEPT[0]['First_Name']; 

$certCount = Certifications::where('Last_Name','=',$lastNames) 
->where('First_Name','=',$firstNames) 

->count(); 
if ($certCount < 1) 
{ 
$certifications1 = "N/A"; 
} 
else 
{ 
$certifications1 = " "; 
} 

$certifications = Certifications::where('Last_Name','=',$lastNames) 
->where('First_Name','=',$firstNames) 

->get(); 

$advisment = Advisment::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 

$fsCount = $facultydata = Facultydata::where('Last_Name','=',$lastNames)    
->where('First_Name','=',$firstNames) 
->count(); 
if ($fsCount < 1) 
{ 
$facultydata1 = "N/A"; 
} 
else 
{ 
$facultydata1 = " "; 
} 
$facultydata = Facultydata::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 

$eduCount = Facultydegree::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($eduCount < 1) 
{ 
$facultydegree1 = "N/A"; 
} 
else 
{ 
$facultydegree1 = " "; 
} 
$facultydegree = Facultydegree::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 

$comCount = Commembership::where('Last_Name','=',$lastNames)    
->where('First_Name','=',$firstNames) 
->count(); 
if ($comCount < 1) 
{ 
$commembership1 = "N/A"; 
} 
else 
{ 
$commembership1 = " "; 
} 

$commembership = Commembership::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 

$otherCount = OtherPro::where('Last_Name', '=', $lastNames) 
->where('First_Name','=',$firstNames) 
->count(); 
if ($otherCount < 1) 
{ 
$otherpro1 = "N/A"; 
} 
else 
{ 
$otherpro1 = " "; 
} 
$otherpro = OtherPro::where('Last_Name', '=', $lastNames) 
->where('First_Name','=',$firstNames) 
->get(); 

$ptCount = PriorTeaching::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($ptCount < 1) 
{ 
$priorteaching1 = "N/A"; 
} 
else 
{ 
$priorteaching1 = " "; 
} 
$priorteaching = PriorTeaching::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 

$pubCount = Publications::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($pubCount < 1) 
{ 
$publication1 = "N/A"; 
} 
else 
{ 
$publication1 = " "; 
} 
$publication = Publications::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 
$pcCount = ProfessionCourse::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($pcCount < 1) 
{ 
$professioncourse1 = "N/A"; 
} 
else 
{ 
$professioncourse1 = " "; 
} 
$professioncourse = ProfessionCourse::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 
$supportCount = Support::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($supportCount < 1) 
{ 
$support1 = "N/A"; 
} 
else 
{ 
$support1 = " "; 
} 
$support = Support::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 

$osCount = OtherSchool::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->count(); 
if ($osCount < 1) 
{ 
$otherschool1 = "N/A"; 
} 
else 
{ 
$otherschool1 = " "; 
} 
$otherschool = OtherSchool::where('Last_Name','=',$lastNames)   
->where('First_Name','=',$firstNames) 
->get(); 
$allDEPTs = View::make('faculty/dept', compact('allDEPT','certifications','certifications1','advisment','facultydata','facultydata1','facultydegree','facultydegree1','commembership', 'commembership1','otherpro','otherpro1','priorteaching','priorteaching1','publication','publication1','professioncourse','professioncourse1','support','support1','otherschool','otherschool1')); 



return $allDEPTs; 
//$queries = DB::getQueryLog(); 
//$last_query = end($queries); 
//var_dump($last_query); 
//die(); 
} 

In meinem Weg habe ich die Variable auf den uri

//faculty get users by department// 
Route::get('faculty/dept/{department}', 
    '[email protected]' 
    ); 

Als ich Fakultät/Abteilung tun/ACDS gehe ich Daten bekommen Hier ein Bild von ihm ist Working before pagination

Wenn ich als nächstes klicken erhalte ich die Fehler
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
Dies ist uri ich, wenn ich das nächste/facultyform/Fakultät/Abteilung klicken, erhalten? Page = 2
vielleicht muss ich machen es geht stattdessen/facultyform/faculty/dept/department? page2?


Hier weitere Informationen des Fehlers ich immer bin
GET Daten
Schlüssel Wert
Seite 2
POST Daten leer
Dateien leer
Hier ist ein funktionierendes url
/facultyform/Fakultät/Abt./Gesundheit% 20Wissenschaft% 20und% 20Technologien?page = 2
Jetzt muß ich nur noch die Abteilung in der URL bekommen und ich bin fertig :)

+0

von wo aus man faculty_id bekommen? Es ist nicht in der Route enthalten. Hast du eine andere Route, um die ID zu übergeben? – ClearBoth

+0

Ich habe eine Route erstellt Route :: Post ('/', Array ( 'als' => 'faculty.create', 'verwendet' => 'FacultyController @ getID' )); Dies verwendet dann ein Formular, das die ID erhält –

+0

So viel falsch mit dem Fluss und der Organisation .... Sie sind hardcoding alles. – itachi

Antwort

0

Wenn ich zu der Ansicht, ich bin in der Lage, die Abteilung zu codieren und alle Arbeiten Jetzt brauche ich nur das weitergeben Variable von der Steuerung zu der Ansicht

 {{ Form::open(array(
    'route' => ['faculty/dept/{department}','ACDS'], 
    'method' => 'post', 
    'id' => 'form-getdept-setting' 
))}} 

{{ Form::label('faculty_id', 'Faculty Id:') }} 
{{ Form::text('faculty_id', '', array(
    'id' => 'faculty_id', 
    'placeholder' => 'Enter Faculty Id', 
    'maxlength' => 20, 
    'required' => true, 
)) }} 


{{ Form::submit('Find Information', array(
    'id' => 'btn-getdeptsetting', 
)) }} 

{{ Form::close() }} 


public function getAllDept2($department){ 
if (Session::token() !== Input::get('_token')) { 
return Response::json(array(
'msg' => 'Unauthorized attempt to create setting' 
)); 
} 

$fId = Input::get('faculty_id'); 

$faculty = Facultyform::where('File_Number', '=', $fId) 
->get(); 
if($faculty[0]['isChair'] == 'Y'){ 
$department = Facultyform::where('Home_Department_Desc', '=',$department)->get(); 
$department2 = $department[0]['Home_Department_Desc']; 
$allDEPT2 = $faculty[0]['Home_Department_Desc']; 
dd($department); 
$allDEPT = Facultyform::where('Home_Department_Desc', '=', $allDEPT2)->paginate(1); 
$this->getAllDept($allDEPT2); 
$lastNames = $allDEPT[0]['Last_Name']; 
$firstNames = $allDEPT[0]['First_Name']; 
$certCount = Certifications::where('Last_Name','=',$lastNames) 
->where('First_Name','=',$firstNames) 

->count(); 
... 
$allDEPTs = View::make('faculty/dept',compact('allDEPT','certifications','certifications1' 
,'advisment','facultydata','facultydata1','facultydegree','facultydegree1','commembership', 
'commembership1','otherpro','otherpro1','priorteaching','priorteaching1','publication' 
,'publication1','professioncourse','professioncourse1','support','support1','otherschool' 
,'otherschool1')); 
return $allDEPTs; 
/* $queries = DB::getQueryLog(); 
$last_query = end($queries); 
var_dump($last_query); 
die(); */ 
} 
else{ 
return Redirect::to('/'); 
} 
} 
Verwandte Themen