Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我在一个控制器中有两个函数,我需要在一个路由上使用,或者我想在另一个func中调用func_Php_Controller_Routes_Laravel 5.4 - Fatal编程技术网

Php 我在一个控制器中有两个函数,我需要在一个路由上使用,或者我想在另一个func中调用func

Php 我在一个控制器中有两个函数,我需要在一个路由上使用,或者我想在另一个func中调用func,php,controller,routes,laravel-5.4,Php,Controller,Routes,Laravel 5.4,我想调用第二个func,比如Route::get('/','AnimeController@bolumler'); 但不能这样做,第二个功能给每个动画所有的插曲第一个功能给一些动画名称和图像URL如果我不能用相同的路线我怎么能?好的,我们不能使用相同的路由,但如果我可以在bolumler func中调用anasayfa func?您需要更改第二条路由的路径或方法。否则,您将有一个重复的路由。您不能对所有路由使用相同的路由。请尝试以下操作:route::get('/{id}','AnimeCont

我想调用第二个func,比如
Route::get('/','AnimeController@bolumler');

但不能这样做,第二个功能给每个动画所有的插曲第一个功能给一些动画名称和图像URL如果我不能用相同的路线我怎么能?好的,我们不能使用相同的路由,但如果我可以在bolumler func中调用anasayfa func?

您需要更改第二条
路由的路径或方法。否则,您将有一个重复的路由。您不能对所有路由使用相同的路由。请尝试以下操作:
route::get('/{id}','AnimeController@bolumler');  
您可以拨打
domain.com/15
(15这是您的id)
public function anasayfa() //this is my first func
{
  $rastgele = Anime::inRandomOrder()->take(7)->get();
  foreach ($rastgele as $random) {
    $random->adi = substr($random->adi, 0,18);
  }
  $son = Anime::orderBy('created_at','desc')->take(7)->get(); // select * from animes orderby created_at dec limit 7
  foreach ($son as $anime) {
    $anime->adi = substr($anime->adi, 0,18);
  }

  return view('anasayfa',compact('rastgele','son'));
}
Route::get('/','AnimeController@anasayfa'); // this is route 
public function bolumler($id) // this is second function
{
  $episode = Anime::find($id)->bolumler;
  return view('anasayfa',compact('episode'));
}