0
I am creating a system in Aravel 5.3, already activated the auth and put a Carousel in the Welcome view that searches the address of the images in the bank. When accessing the default Welcome view path, it gives the error of «the method does not exist». I created a controller, I downloaded the same view on a route with this controller, it gives another error. Here’s the code for best perp:
View Welcome
@extends('portal.template')
@section('content')
<div class="container">
<div id="carousel-example-generic" class="carousel slide carousel-home" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
@foreach($postCarousel as $postCar)
{{--<li data-target="#carousel-example-generic" data-slide-to="{{$i}}"></li>--}}
<li data-target="#carouselExampleIndicators" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' :'' }}"></li>
@endforeach
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
@foreach($postCarousel as $item)
<div class="item {{ $loop->first ? 'active' : '' }}">
<img src="{{$item->imagem}}" alt="...">
<div class="carousel-caption" style="background-color: rgba(133,178,0,0.7)">
<p><h3>{{$item->titulo}}</h3></p>
</div>
</div>
@endforeach
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<hr>
<div class="row">
@foreach ($postsSite as $key =>$value)
<div class="col-sm-3 col-md-4">
<div class="thumbnail">
<img src="{{$value->imagem}}" alt="{{$value->titulo}}">
<div class="noticia-titulo-home" >
<p class="titVisualizado"><b>{{$value->titulo}}</b></p>
</div>
<div class="noticia-conteudo-home">
<p class="contVisualizado">{{$value->descricao}}</p>
</div>
<div class="caption" style="height: 20px; padding: 5px" >
<p>
<a href="{{url('visualizar-noticia/'.$value->id)}}" class="btn btn-success" role="button">Ler Mais</a>
</p>
</div>
<div class="caption" style="height: 25px; padding: 5px" >
<p>
{{--<span class="pull-right" style="color: #e38d13">{{$value->created_at->diffForHumans()}}</span>--}}
<span class="pull-right" style="color: #e38d13">{{$value->created_at}}</span>
</p>
</div>
</div>
</div>
@endforeach
<p>
<a style="width: 99%; font-size: 14pt" href="{{url('index-noticia')}}" class="btn btn-success" role="button">VER MAIS NOTÍCIAS <i class="glyphicon glyphicon-forward"></i></a>
</p>
</div>
</div>
@endsection
Controller
public function getPostsCarousel()
{
return Post::orderBy('id', 'DESC')->take(5)->get();
}
public function getPostsSite()
{
return Post::orderBy('id', 'DESC')->take(6)->get();
}
Route
Route::get('/', function (){
return view('portal.welcome')
->with('postCarousel', $this->getPostsCarousel())
->with('postsSite', $this->getPostsSite());
});
Error
BadMethodCallException in Macroable.php line 74: Method getPostsCarousel does not exist.
Sitecontroller
public function index()
{
return view('portal.welcome', [
'postCarousel' => $this->getPostsCarousel(),
'postsSite' => $this->getPostsSite()
]);
}
Route with controller
Route::group(['prefix' => 'portal'], function (){
Route::get('/','Portal\SiteController@index');
});
Another mistake
NotFoundHttpException in RouteCollection.php line 161:
After 2 weeks nobody helps me? People, please, I really need your help with the above question.
– Daniel dos Santos