title: how to use model function from view ? - laravel 5.4
body: <p>i made a function into model class which is</p>
  
  <pre><code>public function scopetest($query)
      {
   return $query-&gt;pluck('name');
      }
    }
  </code></pre>
  
  <p>and my controller code is </p>
  
  <pre><code> public function index()
       {
       $books = Book::all();
  
       return view('welcome',compact('books'));
  
         }
  </code></pre>
  
  <p>to get the test() function result I wrote my view file</p>
  
  <pre><code>@foreach($books as $book)
  
   {{$book-&gt;test()}}
  
  @endforeach
  </code></pre>
  
  <p>but problem is when i visit this page it will show 'name' field value 3 times. why it show 3 times? how to call model function from view? &amp; what is the right process? kindly help please<a href="https://i.stack.imgur.com/glnqP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/glnqP.png" alt="view result"></a></p>