Я работаю с laravel, чтобы проверить запрос на публикацию и затем показать предупреждение на той же странице. я попытался вернуть последний URL, используя back с сообщением, но не смог увидеть сообщение.
Это моя функция контроллера
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;
use App\Category;
use App\Glassfilm;
use DB;
use Session;
public function checkProduct(Request $request){
$this->validate($request,[
'area' => 'required',
]);
if($request->area <= $request->stock){
//echo "the product is available";
//echo $request;
//Session::flash('message', "available");
echo back();
// return back()->with(['success' => 'Success']);
}
else{
echo "the product is not available";
echo $request;
}
// echo $request;
}
Мой маршрут
Route :: get ('/ glassfilm / {name} / {id}', 'GlassFilmController @ search_by_id');
Route :: post ('/ checkproduct', 'GlassFilmController @ checkProduct') -> name ('check-product');
мой взгляд
@extends ('glassfilm.master')
@section ('title')
{{$name}}
@endsection
@section('message')
@if(Session::has('success'))
<div class="alert alert-success" role="alert">
{{ Session::get('success') }}
</div>
@endif
@endsection
@section ('category')
<ul class="main-categories">
@foreach($category as $category)
<li class="main-nav-list"><a href="{{url('/glassfilm/'.$category->category)}}">{{ $category->category }}<span class="number">({{ $category->count}})</span></a></li>
@endforeach
</ul>
@endsection
@section ('glassfilm')
<section class="lattest-product-area pb-40 category-list">
<div class="row">
<!-- single product -->
@foreach($filterResult as $glass)
<div class="col-lg-3 col-md-6">
<div class="single-product">
@foreach(json_decode($glass->image) as $key=>$image)
@if($loop->first)
<a href="{{url('/glassfilm/'.$category->category.'/'.$glass->id)}}"><img class="img-fluid" src="{{asset('storage')}}/{{$image}}" alt="" style=" width: 263px; height: 280px "></a>
@endif
@endforeach
<div class="product-details">
<h6>{{ $glass->name }}</h6>
<div class="price">
<h6>₹{{ $glass->price - ($glass->price * $glass->discount )/100 }}/sqft</h6>
<h6 class="l-through"> ₹{{ $glass->price }}/sqft</h6>
</div>
<div class="prd-bottom">
<a href="" class="social-info">
<span class="ti-bag"></span>
<p class="hover-text">add to bag</p>
</a>
<a href="" class="social-info">
<span class="lnr lnr-move"></span>
<p class="hover-text">view more</p>
</a>
</div>
</div>
</div>
</div>
@endforeach
<!-- single product -->
</div>
</section>
@endsection