Laravel 确定它来自哪种方法

Laravel 确定它来自哪种方法,laravel,laravel-5.3,Laravel,Laravel 5.3,我有两种方法都返回视图: public function method1() { return ('view1'); } 及 在视图中,我想编辑有关它来自哪个方法的一些更改: 类似于view1中的内容: @if(coming form method1) { This is coming from method1, } @endif 这怎么可能实现呢?目前,我只做了两个单独的视图来进行如此小的更改。为什么不在方法中添加一个标志呢 public function method1() {

我有两种方法都返回视图:

public function method1()
{
  return ('view1');
}

在视图中,我想编辑有关它来自哪个方法的一些更改:

类似于view1中的内容:

@if(coming form method1)
{
   This is coming from method1,
}
@endif

这怎么可能实现呢?目前,我只做了两个单独的视图来进行如此小的更改。

为什么不在方法中添加一个标志呢

public function method1()
{
  $flag = 'method1';
  return ('view1', compact('flag'));
}

public function method2()
{
  $flag = 'method2';
  return ('view1', compact('flag'));
}
并在视图中检查标志

@if ($flag == 'method1')
   This is coming from method1
@elseif ($flag == 'method2')
   This is coming from method2
@endif
@if ($flag == 'method1')
   This is coming from method1
@elseif ($flag == 'method2')
   This is coming from method2
@endif