dimanche 10 novembre 2019

Unable to see the Alert in the blade view in laravel

I am working with laravel to check the post request and then show the alert in the same page. i tried to return the last url using back with a message but i am unable to see the message.

This is my controller function

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;
}

My route

Route::get('/glassfilm/{name}/{id}' , 'GlassFilmController@search_by_id');

Route::post('/checkproduct' , 'GlassFilmController@checkProduct')->name('check-product');

my view

@extends ('glassfilm.master')

@section ('title')
        
@endsection

@section('message')

@if(Session::has('success'))
<div class="alert alert-success" role="alert">
  
</div>
@endif

@endsection
@section ('category')

                    <ul class="main-categories">

                        @foreach($category as $category)
                        <li class="main-nav-list"><a href=""><span class="number">()</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=""><img class="img-fluid" src="/" alt="" style=" width: 263px; height: 280px "></a>
                                    @endif
                                @endforeach
                                <div class="product-details">
                                    <h6></h6>
                                    <div class="price">
                                        <h6>&#x20B9;/sqft</h6>
                                        <h6 class="l-through"> &#8377;/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


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire