crud with modal in lravel

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
	Open Form
</button>

<!-- Modal -->
<div wire:ignore.self class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true close-btn">×</span>
                </button>
            </div>
           <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label for="exampleFormControlInput1">Name</label>
                        <input type="text" class="form-control" id="exampleFormControlInput1" placeholder="Enter Name" wire:model="name">
                        @error('name') <span class="text-danger error">{{ $message }}</span>@enderror
                    </div>
                    <div class="form-group">
                        <label for="exampleFormControlInput2">Email address</label>
                        <input type="email" class="form-control" id="exampleFormControlInput2" wire:model="email" placeholder="Enter Email">
                        @error('email') <span class="text-danger error">{{ $message }}</span>@enderror
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary close-btn" data-dismiss="modal">Close</button>
                <button type="button" wire:click.prevent="store()" class="btn btn-primary close-modal">Save changes</button>
            </div>
        </div>
    </div>
</div>

3
1
Phoenix Logan 186120 points

                                    &lt;?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Customer;
use Redirect,Response;
class CustomerController extends Controller
{

	/**
	* Display a listing of the resource.
	*
	* @return \Illuminate\Http\Response
	*/

	public function index()
	{
		$customers = Customer::latest()-&gt;paginate(4);
		return view('customers.index',compact('customers'))-&gt;with('i', (request()-&gt;input('page', 1) - 1) * 4);
	}

	/**
	* Show the form for creating a new resource.
	*
	* @return \Illuminate\Http\Response
	*/

	public function create()
	{
		return view('customers.create');
	}

	/**
	* Store a newly created resource in storage.
	*
	* @param \Illuminate\Http\Request $request
	* @return \Illuminate\Http\Response
	*/

	public function store(Request $request)
	{

		$r=$request-&gt;validate([
		'name' =&gt; 'required',
		'email' =&gt; 'required',
		'address' =&gt; 'required',
		]);

		$custId = $request-&gt;cust_id;
		Customer::updateOrCreate(['id' =&gt; $custId],['name' =&gt; $request-&gt;name, 'email' =&gt; $request-&gt;email,'address'=&gt;$request-&gt;address]);
		if(empty($request-&gt;cust_id))
			$msg = 'Customer entry created successfully.';
		else
			$msg = 'Customer data is updated successfully';
		return redirect()-&gt;route('customers.index')-&gt;with('success',$msg);
	}

	/**
	* Display the specified resource.
	*
	* @param int $id
	* @return \Illuminate\Http\Response
	*/

	public function show(Customer $customer)
	{
		return view('customers.show',compact('customer'));
	}

	/**
	* Show the form for editing the specified resource.
	*
	* @param int $id
	* @return \Illuminate\Http\Response
	*/
	
	public function edit($id)
	{
		$where = array('id' =&gt; $id);
		$customer = Customer::where($where)-&gt;first();
		return Response::json($customer);
	}

	/**
	* Update the specified resource in storage.
	*
	* @param \Illuminate\Http\Request $request
	* @param int $id
	* @return \Illuminate\Http\Response
	*/

	public function update(Request $request)
	{

	}

	/**
	* Remove the specified resource from storage.
	*
	* @param int $id
	* @return \Illuminate\Http\Response
	*/

	public function destroy($id)
	{
		$cust = Customer::where('id',$id)-&gt;delete();
		return Response::json($cust);
	}
}

3 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
crud modal ajax laravel implement bootstrap modal in livewire laravel crud with modal install bootstrap in livewire livewire bootstrap modal from component laravel 8 livewire modal livewire and bootstrap modal issues open modal with livewire laravel use livewire with bootstrap crud modal laravel bootstrap livewire laravel modal crud livewire ui boostrap modal laravel livewire with bootstrap 5 laravel crud with popup modal trough jquery laravel crud with pop up modal laravel crud with popup modal laravel 8 crud modal popup laravel 7 crud using modal laravel 7 crud modal laravel 8 livewire with bootstrap crud with modal in ;laravel crud modal laravel 8 livewire wire:model in bootstrap modal laravel livewire modal component livewire modal component bootstrap livewire bootstrap modals modal crud form in laravel Ajax laravel crud with popup modal use bootstrap modal with livewire laravel livewire success modal livewire open bootstrap modal laravel crud using modal laravel &quot;livewire&quot; modal laravel crud modal ajax laravel livewire bootstrap modal crud laravel crud laravel 8 modal popup livewire bootstrap laravel 8 livewire bootstrap install laravel 8 livewire bootstrap livewire bootstrap js bootstrap js liveware laravel image popup livewire modal popup form group livewire how to view data on modal using livewire using livewire modal open bootstrap model livewire laravel livewire modal example laravel livewire open modal view laravel livewire open modal laravel livewire popup ajax modal laravel laravel crud bootstrap modal close button laravel crud bootstrap modal livewire show modal laravel livewire modal crud with comfire delete livewire edit with modal datatable livewire modal disappears when typing livewire after update in modal livewire crud modal not displaying validation error laravel livewire dynamic dropdown in bootstrap modal livewire component for show modal by event livewire add recode by listener bootstarp modal livewire modal example show and hide modal livewire livewire html modals laravel install livewire bootstrap livewire install bootstrap bootstrap modal inside livewire component livewire add modal to modal stack livewire popup modal laravel 8 bootstrap with livewire laravel livewire with bootstrap livewire bootstrap modal liveware with bootstrap Laravel CRUD: Bootstrap Modal laravel 7 crud bootstrap modal livewire create modal box laravel livewire modal fade d-block laravel livewire load modal with data javascript laravel livewire modal bootstrap crud with modal in lravel laravel livewire modals package use bootstrap with livewire data table livewire with editable modal editar con modal laravel livewire livewire crud modal laravel livewire events open modal in a tab laravel livewire bootstrap modal livewire bootstrap css livewire bootstrap use laravel livewire dynamic modal bootstrap modal laravel livewire laravel livewire open bootstrap modal laravel livewire modal show laravel livewire show modal livewire button click open modal livewire popup how to integrate laravel livewire with bootstrap livewire bootstrap modal problem load data to bootstrap modal livewire laravel livewire modal livewire laravel popup package bootstrap modal livewire crud users with livewire bootstrap livewire popup laravel implement bootstrap css in laravel with livewire laravel bootstrap livewire laravel livewire crud modal livewire model popup popup modal livewire livewire crud bootstrap livewire bootstrap laravel livewire modal form livewire with bootstrap
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source