У меня 2 функции в контроллереLaravel передать переменную из 1 функции контроллера к другому одному
Это функция Получить
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;
}
Это функция сообщению
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;
}
Я созданы оба маршрута
Route::get('faculty/dept',array(
'uses' => '[email protected]'
));
Route::post('faculty/dept', array(
'as' => 'faculty/dept',
'uses' => '[email protected]'
));
Когда конечный пользователь использует факультет/getDept и помещает идентификатор, он отображает первый элемент в списке, используя представление, но когда я нажимаю на следующую страницу, я получаю следующую ошибку: Отсутствует аргумент 1 для FacultyController :: getAllDept () Если я жестко кодирую департамент, то разбиение на страницы работает, но только для жестко закодированного отдела.
Я пробовал $ this-> getALLDept ($ allDEPT2); Я попытался создать сеанс переменной Я попытался сделать переменную global Есть ли что-то, что я могу сделать в контроллере, чтобы передать переменную из одной функции в другую функцию или я делаю это на маршруте?
Это то, что одна из функций выглядеть
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'));
я делал один для каждого отдела, который просил его. У меня было 3 (все, финансовые и академические), пока это ударило меня, чтобы сделать так, чтобы каждый стул отделения мог просматривать только информацию своего отдела, введя их учетные данные. Безопасность работы просто хочет передать свой отдел в другую функцию
Я сделал переменную в контроллере называемого отделом
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();
}
В моем маршруте я добавил переменный в Ури
//faculty get users by department//
Route::get('faculty/dept/{department}',
'[email protected]'
);
Когда я занимаюсь факультетом/кафедрой/ACDS, я получаю данные Вот этот код
Когда я нажимаю затем я получаю ошибку
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
Это Ури я получаю, когда я нажимаю следующий/facultyform/факультет/отделом? Страница = 2
может быть, я должен сделать это go/facultyform/факультет/отдел/отдел? page2 вместо этого?
Вот подробнее ошибки я получаю
GET данных
Значение ключа
страница 2
POST данных пустой
файлов пустой
Вот работающий URL
/facultyform/факультет/отдел/Здоровье% 20Science% 20and% 20Technologies?страница = 2
Теперь я просто должен получить отдел в URL, и я сделал :)
откуда вы получаете faculty_id? он не включен в маршрут. У вас есть другой маршрут для передачи идентификатора? – ClearBoth
Я создал маршрут Route :: post ('/', array ( 'as' => 'faculty.create', 'uses' => 'FacultyController @ getID' )); В этом случае используется форма, которая получает идентификатор –
. Так что неправильно с потоком и организацией .... Вы все жестко кодируете. – itachi