My problem is this:
I uploaded the data to the view banner, which is included in the view main, which in turn is expanded in the home view, is working well. But when I try to access another view (view create-lemma) in which the view main is also expanded, the following error appears:
Undefined variable: motto (View: C: \ xampp \ htdocs \ GEIGRE \ resources \ views \ pages \ banner.blade.php) (View: C: \ xampp \ htdocs \ GEIGRE \ resources \ views \ pages \ banner.blade.php) (View: C: \ xampp \ htdocs \ GEIGRE \ resources \ views \ pages \ banner.blade.php)
I need help. And thank you in advance.
Here's the code.
LemaController
public function create()
{
$lema=new Lema;
$lema->texto_lm = Input::get('texto');
$lema->refBilblica_lm = Input::get('refBiblica');
$lema->status_lm = Input::get('status');
$lema->save();
return redirect('/');
}
HomeController
use App\Lema;
use Redirect;
class HomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$lema = Lema:: where('status_lm', 'Activo')->get();
return view('home')->with('lema',$lema);
}
}
Route
Route::get('criar-lema', function () {
return view('lema.create-lema');
});
Route::post('criar-lema', 'LemaController@create');
Route::get('/', 'HomeController@index');
view banner
<div class="page-header page-header-home">
<div class="container" style="margin-bottom: 0px; background-color: #85B200">
<img src="/images/logo.png.png" alt="...">
<a href="#"> <i class="glyphicon glyphicon-user" style="float: right; position: relative; margin-top: 100px; margin-right: 20px; color: #FFFFFF">Iniciar Sessão</i></a>
<div style="background-color: #4C6600; width: 450px; height: 90px; border-radius: 15px; position: relative; float: right; margin-right: 190px; margin-top: 22px">
<?php foreach ($lema as $key => $value): ?>
<p style="padding: 0px; text-align: center; font-family: 'Tw Cen MT', Arial, 'Helvetica LT Std';font-size: 26px; color: #ffffff">{!! $value->texto_lm !!}</p>
<p style="padding: 0px; text-align: center; font-family: 'Tw Cen MT', Arial, 'Helvetica LT Std';font-size: 15px; color: #ffffff">{!! $value->refBilblica_lm !!}</p>
<?php endforeach; ?>
</div>
</div>
</div>
view main
<!DOCTYPE HTML>
<html>
@include("paginas.head")
<body>
@include("paginas.banner")
@include("paginas.menu")
<div class="container">
@yield("content")
</div>
</body>
</html>
view home
@extends('main')
@section('content')
<div id="carousel-example-generic" class="carousel slide carousel-home" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="/images/17.jpg" alt="...">
<div class="carousel-caption">
<p>Canguru </p>
</div>
</div>
<div class="item">
<img src="/images/12.jpg" alt="...">
<div class="carousel-caption">
<p>Tubarão</p>
</div>
</div>
<div class="item">
<img src="/images/22.jpg" alt="...">
<div class="carousel-caption">
<p>Cão</p>
</div>
</div>
</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>
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="/images/logo1.jpg" alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>
</div>
@endsection
view create-motto
@extends('main')
@section('content')
<div style="background-color: #c9e2b3; padding: 5px 10px">
<br />
<h2>NOVO LEMA</h2>
<br />
<form action="{{url('criar-lema')}}" method="post" enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="form-group">
<label for="texto">Texto</label>
<input name="texto" type="text" class="form-control" id="texto" placeholder="Insira aqui o texto do lema">
</div>
<div class="form-group">
<label for="refBiblica">Ref. Bíblica</label>
<input name="refBiblica" type="text" class="form-control" id="refBiblica" placeholder="Referência Bíblica">
</div>
<div class="form-group">
<label for="status">Status</label>
<input name="status" type="text" class="form-control" id="status" placeholder=" insira 'Activo' ou 'Não Activo'">
</div>
<button type="submit" class="btn btn-success">Salvar</button>
</form>
</div>
@endsection