mercredi 3 mars 2021

How to break line in textarea in laravel and then echo it by foreach loop?

The name of my controller is ProductController, This is my controller

public function store(Request $request)
{
    $request->validate([
        'product_name' => 'required',
        'product_detail' => 'required',
        'product_image' => 'required',
        'admin_name' => 'required',
    ]);
    $product_image = $request->file('product_image');
    $new_name = rand().'.'.$product_image->getClientOriginalExtension();
    $product_image->move(public_path('product_image'), $new_name);
    $form_data = array(
        'product_image' => $new_name,
    );
    // Product::create($form_data);
    
    $product = Product::create([
        'product_name' => $request->input('product_name'),
        'product_detail' => $request->input('product_detail'),
        'admin_name' => $request->input('admin_name'),
        'product_image' => $new_name,
    ]);

    return redirect('products')->with('success', 'Data Added successfully.');
}

This is my index page where I want to echo it, I have doubt in Product_detail

@foreach($products as $product)
                    <div class="col-lg-4 col-md-6 portfolio-item filter-Interior">
                        <div class="portfolio-wrap">
                            <div class="portfolio-info">
                                <h4></h4>
                                <p>
                                    <ul style="color: white">
                                            <li></li>
                                    </ul>
                                </p>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire