<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>crud Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/crud/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/crud/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Wed, 13 Apr 2022 16:33:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Target class [PostController] does not exist.</title>
		<link>https://www.scmgalaxy.com/tutorials/target-class-postcontroller-does-not-exist/</link>
					<comments>https://www.scmgalaxy.com/tutorials/target-class-postcontroller-does-not-exist/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Fri, 21 May 2021 12:02:07 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[crud operation in laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=6315</guid>

					<description><![CDATA[<p>Whenever you got this types of error go to your Route/web.php file and checkout your Controller class is mention there [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/target-class-postcontroller-does-not-exist/">Target class [PostController] does not exist.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/2732/1*zYXhZ0W-6FNZD4gN90uQIQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="9f4a">Whenever you got this types of error go to your Route/web.php file and checkout your Controller class is mention there or not.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1366/1*dknFRNBrkf7i3jNGw5aJPQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="c977">Next Go to PostController file and copy your controller class</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1366/1*shUfc-bV_sUa7VQhtWqBhQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="8e2f">Now go to Routes/web.php and class this class</p>



<pre class="wp-block-preformatted">use App\Http\Controllers\PostController;</pre>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1366/1*T3oto9BjfSeFrEXyRRLPbw.png" alt=""/></figure>



<pre class="wp-block-preformatted">php artisan serve</pre>



<p class="wp-block-paragraph" id="dd66">Now its working properly</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1276/1*N4nSNuQMwFyD8PUAxWB0tw.png" alt=""/></figure>



<p class="wp-block-paragraph" id="57db">Thanks.</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/target-class-postcontroller-does-not-exist/">Target class [PostController] does not exist.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/target-class-postcontroller-does-not-exist/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CRUD Operations in Laravel using ajax</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-using-ajax/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-using-ajax/#respond</comments>
		
		<dc:creator><![CDATA[dharmendra K]]></dc:creator>
		<pubDate>Tue, 11 May 2021 16:34:09 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[modal]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=6182</guid>

					<description><![CDATA[<p>Step 1 &#8211; Install Laravel 5.8 First we want to Download Laravel 5.8 version for developing Crud application using Ajax. [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-using-ajax/">CRUD Operations in Laravel using ajax</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><strong>Step 1</strong> &#8211; Install Laravel 5.8</p>



<p class="wp-block-paragraph">First we want to Download Laravel 5.8 version for developing Crud application using Ajax. For this you have to open your terminal or command prompt and write below command. It will download Laravel 5.8 in your define directory.</p>



composer create-project laravel/laravel=5.8 ajax-crud &#8211;prefer-dist



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="743" height="122" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/05/25.jpg" alt="" class="wp-image-6183" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/05/25.jpg 743w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/05/25-300x49.jpg 300w" sizes="(max-width: 743px) 100vw, 743px" /></figure>



<p class="wp-block-paragraph"><strong>Step 2</strong> &#8211; Laravel 5.8 Database Connection</p>



<p class="wp-block-paragraph">Once Laravel 5.8 has been downloaded then after we have to make Database connection. For this first you have to open <strong>config/database.php</strong> and define Mysql Database configuration.</p>



<script src="https://gist.github.com/dharmu9898/a76d548c8ab44393cc6e01f6e7c4bce0.js"></script>



<p class="wp-block-paragraph">After this you have to open <strong>.env</strong> file and in that file also you have to define Mysql Database configuration, which you can find below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="301" height="133" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/05/25-1.jpg" alt="" class="wp-image-6184"/></figure>



<p class="wp-block-paragraph"><strong>Step 3</strong> &#8211; Create Table</p>



<p class="wp-block-paragraph">For Create Crud Application, first we have to create Mysql table. For create Mysql table from Laravel 5.8 application we have to write following artisan command in your command prompt.</p>



php artisan make:migration create_ajax_cruds_table &#8211;create=ajax_cruds



<p class="wp-block-paragraph">Above command will command create migration file in <strong>database/migrations</strong> folder. In that file we have to define table column which you want to define in Mysql table. Below you can find source code of migration file.</p>



<script src="https://gist.github.com/dharmu9898/0a7e2ea0a775da52337a1c494b32ea78.js"></script>



<p class="wp-block-paragraph">Lastly for create Mysql table in your Database, you have to write following command in your terminal or command prompt. It will create <strong>ajax_cruds</strong> table in your define Database.</p>



php artisan migrate



<p class="wp-block-paragraph"><strong>Step 4</strong> &#8211; Create Model in Laravel 5.8</p>



<p class="wp-block-paragraph">Now we want to make Model in Laravel 5.8, For this you have to write following command in your terminal or command prompt. It will create model file here <strong>app/AjaxCrud.php</strong>.</p>



php artisan make:model AjaxCrud -m



<p class="wp-block-paragraph">Under this <strong>app/AjaxCrud.php</strong> file, you have to define table column for database operation which source code you can find below.</p>



<script src="https://gist.github.com/dharmu9898/556f38ce8a7ca5b2a556dc5d990c4e77.js"></script>



<p class="wp-block-paragraph"><strong>Step 5</strong> &#8211; Create Blades Files</p>



<p class="wp-block-paragraph">For display output data in browser, in Laravel 5.8 we have to create blade file in <strong>resources/views</strong> folder. Under this folder we have create <strong>ajax_index.blade.php</strong> file. In this file you can find HTML code and jQuery code for display data in jQuery Datatable.</p>



<script src="https://gist.github.com/dharmu9898/3968e27ea73fbabcd031bac639b948c2.js"></script>



<p class="wp-block-paragraph"><strong>Step 6</strong> &#8211; Set Resource Route</p>



<script src="https://gist.github.com/dharmu9898/9f54ca5c26e15cf6d0be57361f50f2fd.js"></script>



<p class="wp-block-paragraph"><strong>Step</strong> 7 &#8211; Create Controller in Laravel 5.8</p>



<p class="wp-block-paragraph">Lastly, We need to set resource route for ajax crud application. For this we have to open <strong>routes/web.php</strong> file.</p>



<p class="wp-block-paragraph">Controller mostly used for handle HTTP request. Create new controller in Laravel 5.8 framework, we have to write following command.</p>



php artisan make:controller AjaxCrudController &#8211;resource



<p class="wp-block-paragraph">This command will create&nbsp;<strong>AjaxCrudController.php</strong>&nbsp;file in&nbsp;<strong>app/Http/Controllers</strong>&nbsp;folder. In this controller file you can find all in build required method for do Crud operation. Under this controller for use AjaxCrud model, first we have to define&nbsp;<strong>use App\AjaxCrud;</strong>&nbsp;this statement at the header of the AjaxCrudController.php file.</p>



<p class="wp-block-paragraph"><strong>index() &#8211;&nbsp;</strong>This is the root method of this controller. This method will received Ajax request for load data in jQuery DataTables plugin. If this method received ajax request then it will load data in jQuery DataTables plugin. In this ajax block you can find yajra datatables package code.</p>



<p class="wp-block-paragraph"><strong>store() &#8211;&nbsp;</strong>For Insert Data into Mysql table using ajax in Laravel 5.8, here we have use store() method of&nbsp;<strong>AjaxCrudController.php</strong>. This method will received Ajax request for insert or add data. Under this method first it has validate for data. If there is any validation fails then it will send response to ajax request in JSON format. But there is no any validation fails then it will continue execution of code and first it will upload profile image of user and then after it will insert data into mysql table. And lastly it will send json response to ajax request.</p>



<p class="wp-block-paragraph"><strong>edit() &#8211;&nbsp;</strong>This method is used for fetch single row of data from mysql table, and send data to ajax request in json formate which will be display under Bootstrap modal form.</p>



<p class="wp-block-paragraph"><strong>update() &#8211; </strong>This method has received ajax request for update existing mysql table data. In this method first it check user has select profile image or not. If User is select image then in this method it will validate form data with selected file is image or not. But Suppose user has not select image then it will only validate textbox data only. If there is any validation error occur then it will send data to ajax request in json formate. After successfully validate form data then it will update data.</p>



<p class="wp-block-paragraph"><strong>destroy() &#8211; </strong>For delete or remove mysql data, ajax request will be send to destroy() method. It will delete or remove mysql data in Laravel 5.8 by using ajax.</p>



<script src="https://gist.github.com/dharmu9898/9df68fedb88e7746a26e1ad4494304d1.js"></script>



<p class="wp-block-paragraph">For run Laravel 5.8 application, you can write following command.</p>



php artisan serve




<p class="wp-block-paragraph">For see Laravel 5.8 application in your browser, you have to write following url.</p>



http://localhost:8000/ajax-crud
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-using-ajax/">CRUD Operations in Laravel using ajax</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-using-ajax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Crud Operation in Laravel</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operation-in-laravel/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operation-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Mon, 10 May 2021 03:57:48 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=6145</guid>

					<description><![CDATA[<p>In this tutorial I’m going to learn how to create Crud operation in Laravel. Please follow some easy steps define [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-in-laravel/">Crud Operation in Laravel</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph" id="934a">In this tutorial I’m going to learn how to create Crud operation in Laravel. Please follow some easy steps define below.</p>



<h1 class="wp-block-heading" id="8dfa">Step 1 — Installing Laravel 8</h1>



<p class="wp-block-paragraph" id="1434">Open terminal in xampp/htdocs and paste below code</p>



<pre class="wp-block-preformatted">composer create-project laravel/laravel example-app</pre>



<h1 class="wp-block-heading" id="2c3f">Step 2 — Setting up a MySQL Database</h1>



<h1 class="wp-block-heading" id="1a27"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2 — Database Configuration</h1>



<p class="wp-block-paragraph" id="0f04">Setup database with your installed laravel 8 project . lets go to .env folder and put database name and connect to database.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1564/1*GE5yf2VslpIw_QXdKAj3rw.png" alt=""/></figure>



<p class="wp-block-paragraph" id="6ed6"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Next go to .env folder and put database name</p>



<pre class="wp-block-preformatted">DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=crud-operation<br>DB_USERNAME=root<br>DB_PASSWORD=</pre>



<p class="wp-block-paragraph" id="b9c4">Next run this command</p>



<pre class="wp-block-preformatted">php artisan migrate</pre>



<h1 class="wp-block-heading" id="4afe">Step 3 — Creating a Database Migration</h1>



<p class="wp-block-paragraph" id="125c">Run this command</p>



<pre class="wp-block-preformatted">php artisan make:migration create_products_table --create=products</pre>



<p class="wp-block-paragraph" id="1115">Copy below code and simply paste in your products table</p>



<pre class="wp-block-preformatted">&lt;?php<br> <br>use Illuminate\Support\Facades\Schema;<br>use Illuminate\Database\Schema\Blueprint;<br>use Illuminate\Database\Migrations\Migration;<br>  <br>class CreateProductsTable extends Migration<br>{<br>    /**<br>     * Run the migrations.<br>     *<br>     * @return void<br>     */<br>    public function up()<br>    {<br>        Schema::create('products', function (Blueprint $table) {<br>            $table-&gt;increments('id');<br>            $table-&gt;string('name');<br>            $table-&gt;text('detail');<br>            $table-&gt;timestamps();<br>        });<br>    }<br>  <br>    /**<br>     * Reverse the migrations.<br>     *<br>     * @return void<br>     */<br>    public function down()<br>    {<br>        Schema::dropIfExists('products');<br>    }<br>}</pre>



<h1 class="wp-block-heading" id="5cb5">Step 4 — Adding a Resource Route</h1>



<pre class="wp-block-preformatted">&lt;?php<br><br>use Illuminate\Support\Facades\Route;<br><br>/*<br>|--------------------------------------------------------------------------<br>| Web Routes<br>|--------------------------------------------------------------------------<br>|<br>| Here is where you can register web routes for your application. These<br>| routes are loaded by the RouteServiceProvider within a group which<br>| contains the "web" middleware group. Now create something great!<br>|<br>*/<br><br>Route::get('/', function () {<br>    return view('welcome');<br>});<br><br>Route::resource('products','ProductController');</pre>



<h1 class="wp-block-heading" id="ae5f">Step 5 — Adding a Laravel 8 Controller and Model</h1>



<p class="wp-block-paragraph" id="91de">run this command</p>



<pre class="wp-block-preformatted">php artisan make:controller ProductController --resource --model=Product</pre>



<p class="wp-block-paragraph" id="e5f9">Go to your product controller and paste below code</p>



<pre class="wp-block-preformatted">&lt;?php<br>  <br>namespace App\Http\Controllers;<br>  <br>use App\Product;<br>use Illuminate\Http\Request;<br>  <br>class ProductController extends Controller<br>{<br>    /**<br>     * Display a listing of the resource.<br>     *<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function index()<br>    {<br>        $products = Product::latest()-&gt;paginate(5);<br>  <br>        return view('products.index',compact('products'))<br>            -&gt;with('i', (request()-&gt;input('page', 1) - 1) * 5);<br>    }<br>   <br>    /**<br>     * Show the form for creating a new resource.<br>     *<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function create()<br>    {<br>        return view('products.create');<br>    }<br>  <br>    /**<br>     * Store a newly created resource in storage.<br>     *<br>     * @param  \Illuminate\Http\Request  $request<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function store(Request $request)<br>    {<br>        $request-&gt;validate([<br>            'name' =&gt; 'required',<br>            'detail' =&gt; 'required',<br>        ]);<br>  <br>        Product::create($request-&gt;all());<br>   <br>        return redirect()-&gt;route('products.index')<br>                        -&gt;with('success','Product created successfully.');<br>    }<br>   <br>    /**<br>     * Display the specified resource.<br>     *<br>     * @param  \App\Product  $product<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function show(Product $product)<br>    {<br>        return view('products.show',compact('product'));<br>    }<br>   <br>    /**<br>     * Show the form for editing the specified resource.<br>     *<br>     * @param  \App\Product  $product<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function edit(Product $product)<br>    {<br>        return view('products.edit',compact('product'));<br>    }<br>  <br>    /**<br>     * Update the specified resource in storage.<br>     *<br>     * @param  \Illuminate\Http\Request  $request<br>     * @param  \App\Product  $product<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function update(Request $request, Product $product)<br>    {<br>        $request-&gt;validate([<br>            'name' =&gt; 'required',<br>            'detail' =&gt; 'required',<br>        ]);<br>  <br>        $product-&gt;update($request-&gt;all());<br>  <br>        return redirect()-&gt;route('products.index')<br>                        -&gt;with('success','Product updated successfully');<br>    }<br>  <br>    /**<br>     * Remove the specified resource from storage.<br>     *<br>     * @param  \App\Product  $product<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function destroy(Product $product)<br>    {<br>        $product-&gt;delete();<br>  <br>        return redirect()-&gt;route('products.index')<br>                        -&gt;with('success','Product deleted successfully');<br>    }<br>}</pre>



<p class="wp-block-paragraph" id="1293">Lets Go to Model and paste below code</p>



<pre class="wp-block-preformatted">&lt;?php<br>  <br>namespace App;<br>  <br>use Illuminate\Database\Eloquent\Model;<br>   <br>class Product extends Model<br>{<br>    protected $fillable = [<br>        'name', 'detail'<br>    ];<br>}</pre>



<h1 class="wp-block-heading" id="9c87">Step 6 — Adding your Larevl 8 Blade Views</h1>



<p class="wp-block-paragraph" id="4a3f">Go&nbsp;to Resource folder and create view file</p>



<p class="wp-block-paragraph" id="9b41"><strong>1) layout.blade.php</strong></p>



<p class="wp-block-paragraph" id="27e0"><strong>2) index.blade.php</strong></p>



<p class="wp-block-paragraph" id="da8e"><strong>3) create.blade.php</strong></p>



<p class="wp-block-paragraph" id="ba29"><strong>4) edit.blade.php</strong></p>



<p class="wp-block-paragraph" id="0226"><strong>5) show.blade.php</strong></p>



<p class="wp-block-paragraph" id="5e73"><strong>resources/views/products/layout.blade.php</strong></p>



<pre class="wp-block-preformatted">&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Laravel 6 CRUD Application - Laravel Amit&lt;/title&gt;<br>    &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css" rel="stylesheet"&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  <br>&lt;div class="container"&gt;<br>    @yield('content')<br>&lt;/div&gt;<br>   <br>&lt;/body&gt;<br>&lt;/html&gt;</pre>



<p class="wp-block-paragraph" id="f028"><strong>resources/views/products/index.blade.php</strong></p>



<pre class="wp-block-preformatted">@extends('products.layout')<br> <br>@section('content')<br>    &lt;div class="row"&gt;<br>        &lt;div class="col-lg-12 margin-tb"&gt;<br>            &lt;div class="pull-left"&gt;<br>                &lt;h2&gt;Laravel 6 CRUD Example from By Laravel Amit&lt;/h2&gt;<br>            &lt;/div&gt;<br>            &lt;div class="pull-right"&gt;<br>                &lt;a class="btn btn-success" href="{{ route('products.create') }}"&gt; Create New Product&lt;/a&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>   <br>    @if ($message = Session::get('success'))<br>        &lt;div class="alert alert-success"&gt;<br>            &lt;p&gt;{{ $message }}&lt;/p&gt;<br>        &lt;/div&gt;<br>    @endif<br>   <br>    &lt;table class="table table-bordered"&gt;<br>        &lt;tr&gt;<br>            &lt;th&gt;No&lt;/th&gt;<br>            &lt;th&gt;Name&lt;/th&gt;<br>            &lt;th&gt;Details&lt;/th&gt;<br>            &lt;th width="280px"&gt;Action&lt;/th&gt;<br>        &lt;/tr&gt;<br>        @foreach ($products as $product)<br>        &lt;tr&gt;<br>            &lt;td&gt;{{ ++$i }}&lt;/td&gt;<br>            &lt;td&gt;{{ $product-&gt;name }}&lt;/td&gt;<br>            &lt;td&gt;{{ $product-&gt;detail }}&lt;/td&gt;<br>            &lt;td&gt;<br>                &lt;form action="{{ route('products.destroy',$product-&gt;id) }}" method="POST"&gt;<br>   <br>                    &lt;a class="btn btn-info" href="{{ route('products.show',$product-&gt;id) }}"&gt;Show&lt;/a&gt;<br>    <br>                    &lt;a class="btn btn-primary" href="{{ route('products.edit',$product-&gt;id) }}"&gt;Edit&lt;/a&gt;<br>   <br>                    @csrf<br>                    @method('DELETE')<br>      <br>                    &lt;button type="submit" class="btn btn-danger"&gt;Delete&lt;/button&gt;<br>                &lt;/form&gt;<br>            &lt;/td&gt;<br>        &lt;/tr&gt;<br>        @endforeach<br>    &lt;/table&gt;<br>  <br>    {!! $products-&gt;links() !!}<br>      <br>@endsection</pre>



<p class="wp-block-paragraph" id="6eb5"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" />&nbsp;<strong>resources/views/products/create.blade.php</strong></p>



<pre class="wp-block-preformatted">@extends('products.layout')<br>  <br>@section('content')<br>&lt;div class="row"&gt;<br>    &lt;div class="col-lg-12 margin-tb"&gt;<br>        &lt;div class="pull-left"&gt;<br>            &lt;h2&gt;Add New Product&lt;/h2&gt;<br>        &lt;/div&gt;<br>        &lt;div class="pull-right"&gt;<br>            &lt;a class="btn btn-primary" href="{{ route('products.index') }}"&gt; Back&lt;/a&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;<br>   <br>@if ($errors-&gt;any())<br>    &lt;div class="alert alert-danger"&gt;<br>        &lt;strong&gt;Whoops!&lt;/strong&gt; There were some problems with your input.&lt;br&gt;&lt;br&gt;<br>        &lt;ul&gt;<br>            @foreach ($errors-&gt;all() as $error)<br>                &lt;li&gt;{{ $error }}&lt;/li&gt;<br>            @endforeach<br>        &lt;/ul&gt;<br>    &lt;/div&gt;<br>@endif<br>   <br>&lt;form action="{{ route('products.store') }}" method="POST"&gt;<br>    @csrf<br>  <br>     &lt;div class="row"&gt;<br>        &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>            &lt;div class="form-group"&gt;<br>                &lt;strong&gt;Name:&lt;/strong&gt;<br>                &lt;input type="text" name="name" class="form-control" placeholder="Name"&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>            &lt;div class="form-group"&gt;<br>                &lt;strong&gt;Detail:&lt;/strong&gt;<br>                &lt;textarea class="form-control" style="height:150px" name="detail" placeholder="Detail"&gt;&lt;/textarea&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class="col-xs-12 col-sm-12 col-md-12 text-center"&gt;<br>                &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>   <br>&lt;/form&gt;<br>@endsection</pre>



<p class="wp-block-paragraph" id="9c08"><strong>resources/views/products/edit.blade.php</strong></p>



<pre class="wp-block-preformatted">@extends('products.layout')<br>   <br>@section('content')<br>    &lt;div class="row"&gt;<br>        &lt;div class="col-lg-12 margin-tb"&gt;<br>            &lt;div class="pull-left"&gt;<br>                &lt;h2&gt;Edit Product&lt;/h2&gt;<br>            &lt;/div&gt;<br>            &lt;div class="pull-right"&gt;<br>                &lt;a class="btn btn-primary" href="{{ route('products.index') }}"&gt; Back&lt;/a&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>   <br>    @if ($errors-&gt;any())<br>        &lt;div class="alert alert-danger"&gt;<br>            &lt;strong&gt;Whoops!&lt;/strong&gt; There were some problems with your input.&lt;br&gt;&lt;br&gt;<br>            &lt;ul&gt;<br>                @foreach ($errors-&gt;all() as $error)<br>                    &lt;li&gt;{{ $error }}&lt;/li&gt;<br>                @endforeach<br>            &lt;/ul&gt;<br>        &lt;/div&gt;<br>    @endif<br>  <br>    &lt;form action="{{ route('products.update',$product-&gt;id) }}" method="POST"&gt;<br>        @csrf<br>        @method('PUT')<br>   <br>         &lt;div class="row"&gt;<br>            &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>                &lt;div class="form-group"&gt;<br>                    &lt;strong&gt;Name:&lt;/strong&gt;<br>                    &lt;input type="text" name="name" value="{{ $product-&gt;name }}" class="form-control" placeholder="Name"&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>            &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>                &lt;div class="form-group"&gt;<br>                    &lt;strong&gt;Detail:&lt;/strong&gt;<br>                    &lt;textarea class="form-control" style="height:150px" name="detail" placeholder="Detail"&gt;{{ $product-&gt;detail }}&lt;/textarea&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>            &lt;div class="col-xs-12 col-sm-12 col-md-12 text-center"&gt;<br>              &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>   <br>    &lt;/form&gt;<br>@endsection</pre>



<p class="wp-block-paragraph" id="d2b0"><strong>resources/views/products/show.blade.php</strong></p>



<pre class="wp-block-preformatted">@extends('products.layout')<br>@section('content')<br>    &lt;div class="row"&gt;<br>        &lt;div class="col-lg-12 margin-tb"&gt;<br>            &lt;div class="pull-left"&gt;<br>                &lt;h2&gt; Show Product&lt;/h2&gt;<br>            &lt;/div&gt;<br>            &lt;div class="pull-right"&gt;<br>                &lt;a class="btn btn-primary" href="{{ route('products.index') }}"&gt; Back&lt;/a&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>   <br>    &lt;div class="row"&gt;<br>        &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>            &lt;div class="form-group"&gt;<br>                &lt;strong&gt;Name:&lt;/strong&gt;<br>                {{ $product-&gt;name }}<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class="col-xs-12 col-sm-12 col-md-12"&gt;<br>            &lt;div class="form-group"&gt;<br>                &lt;strong&gt;Details:&lt;/strong&gt;<br>                {{ $product-&gt;detail }}<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>@endsection</pre>



<p class="wp-block-paragraph" id="58f0">Lets run php artisan serve</p>



<pre class="wp-block-preformatted">http://localhost:8000/products</pre>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1564/1*26WTHodagS2WpVpH0wHmaQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="0071">I hope its helpful for you.</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-in-laravel/">Crud Operation in Laravel</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/crud-operation-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Add Data in DataTable in Laravel Crud</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-add-data-in-datatable-in-laravel-crud/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-add-data-in-datatable-in-laravel-crud/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Thu, 06 May 2021 11:03:32 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[datatable]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=6094</guid>

					<description><![CDATA[<p>In this tutorial I&#8217;m going to describe how to add data in DataTable in laravel 8 we will create single [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-add-data-in-datatable-in-laravel-crud/">How to Add Data in DataTable in Laravel Crud</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph" id="b01f">In this tutorial I&#8217;m going to describe how to add data in DataTable in laravel 8 we will create single page companies ajax crud application (SPA) using dataTables js, modal and jQuery in laravel 8.</p>



<pre class="wp-block-preformatted">Laravel 8 Ajax CRUD Tutorial using Datatable JS<br>Step 1 – Download Laravel 8 App<br>Step 2 – Database Configuration<br>Step 3 – Installing Yajra Datatables<br>Step 4 – Make Model &amp; Migration<br>Step 5 – Make Routes<br>Step 6 – Create AJAX CRUD Datatables Controller<br>Step 7 – Create Blade Views File<br>companies.blade.php<br>company-action.blade.php<br>Step 8 – Run Development Server</pre>



<h1 class="wp-block-heading" id="b64a">Step 1 — Download Laravel 8 App</h1>



<p class="wp-block-paragraph" id="1b90">1st step Install laravel project and new setup, lets open the terminal C:\xampp\htdocs and paste below code</p>



<pre class="wp-block-preformatted">composer create-project --prefer-dist laravel/laravel laraveldatatable</pre>



<h1 class="wp-block-heading" id="4ff7">Step 2 — Database Configuration</h1>



<p class="wp-block-paragraph" id="be79">Setup database with your installed laravel 8 project . lets go to .env folder and put database name and connect to database.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1366/1*l1fZ0rXU6B1--IbRQweRFA.png" alt=""/></figure>



<pre class="wp-block-preformatted">DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=laraveldatatable<br>DB_USERNAME=root<br>DB_PASSWORD=</pre>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1366/1*pH11rQJuj3RYy-SRAKT2XQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="a301">Next run this command</p>



<pre class="wp-block-preformatted">php artisan migrate</pre>



<h1 class="wp-block-heading" id="9bf6">Step 3 — Installing Yajra Datatables</h1>



<pre class="wp-block-preformatted">composer require yajra/laravel-datatables-oracle</pre>



<p class="wp-block-paragraph" id="6085">Then configure datatables package. So go to config directory and open app.php file. And add the following service providers into app.php file:</p>



<p class="wp-block-paragraph" id="3d41">Go to -&gt; config/app.php and put in providers section</p>



<pre class="wp-block-preformatted">'providers' =&gt; [<br>    <br>   Yajra\Datatables\DatatablesServiceProvider::class,<br>],<br> <br> 'aliases' =&gt; [<br> <br>  'Datatables' =&gt; Yajra\Datatables\Facades\Datatables::class,<br>]</pre>



<p class="wp-block-paragraph" id="21b6">Then publish laravel datatables vendor package by using below command:</p>



<pre class="wp-block-preformatted">php artisan vendor:publish</pre>



<h1 class="wp-block-heading" id="30e5">Step 4 — Make Model &amp; Migration</h1>



<pre class="wp-block-preformatted">php artisan make:model Company -m</pre>



<p class="wp-block-paragraph" id="feed">Simply copy this code and paste in companies model</p>



<pre class="wp-block-preformatted">&lt;?php<br><br>use Illuminate\Database\Migrations\Migration;<br>use Illuminate\Database\Schema\Blueprint;<br>use Illuminate\Support\Facades\Schema;<br><br>class CreateCompaniesTable extends Migration<br>{<br>    /**<br>     * Run the migrations.<br>     *<br>     * @return void<br>     */<br>    public function up()<br>    {<br>        Schema::create('companies', function (Blueprint $table) {<br>            $table-&gt;id();<br>            $table-&gt;timestamps();<br>            $table-&gt;string('name');<br>            $table-&gt;string('email');<br>            $table-&gt;string('address');<br>        });<br>    }<br><br>    /**<br>     * Reverse the migrations.<br>     *<br>     * @return void<br>     */<br>    public function down()<br>    {<br>        Schema::dropIfExists('companies');<br>    }<br>}</pre>



<p class="wp-block-paragraph" id="8256">Lets migrate table to database run this command</p>



<pre class="wp-block-preformatted">php artisan migrate</pre>



<p class="wp-block-paragraph" id="2c99">After that, lets go to app/models directory and open company.php model file. Then add the following code into it:</p>



<pre class="wp-block-preformatted">&lt;?php<br><br>namespace App;<br><br>use Illuminate\Database\Eloquent\Model;<br><br>class Company extends Model<br>{<br>    <br>    protected $fillable =['name', 'email', 'address'];<br><br>}</pre>



<h1 class="wp-block-heading" id="5a00">Step 5 — Make Routes</h1>



<pre class="wp-block-preformatted">&lt;?php<br><br>use Illuminate\Support\Facades\Route;<br><br>/*<br>|--------------------------------------------------------------------------<br>| Web Routes<br>|--------------------------------------------------------------------------<br>|<br>| Here is where you can register web routes for your application. These<br>| routes are loaded by the RouteServiceProvider within a group which<br>| contains the "web" middleware group. Now create something great!<br>|<br>*/<br><br>Route::get('/', function () {<br>    return view('welcome');<br>});<br><br>use App\Http\Controllers\DataTableAjaxCRUDController;<br> <br>Route::get('ajax-crud-datatable', [DataTableAjaxCRUDController::class, 'index']);<br>Route::post('store-company', [DataTableAjaxCRUDController::class, 'store']);<br>Route::post('edit-company', [DataTableAjaxCRUDController::class, 'edit']);<br>Route::post('delete-company', [DataTableAjaxCRUDController::class, 'destroy']);</pre>



<h1 class="wp-block-heading" id="5ea7">Step 6 — Create AJAX CRUD Datatables Controller</h1>



<pre class="wp-block-preformatted">php artisan make:controller DataTableAjaxCRUDController -r</pre>



<p class="wp-block-paragraph" id="0c46">Lets go to controller and copy below code and paste there</p>



<pre class="wp-block-preformatted">&lt;?php<br><br>namespace App\Http\Controllers;<br><br><br>use Illuminate\Http\Request;<br>use App\Company;<br>class DataTableAjaxCRUDController extends Controller<br>{<br>    /**<br>     * Display a listing of the resource.<br>     *<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function index()<br>    {<br>        if(request()-&gt;ajax()) {<br>            return datatables()-&gt;of(Company::select('*'))<br>            -&gt;addColumn('action', 'company-action')<br>            -&gt;rawColumns(['action'])<br>            -&gt;addIndexColumn()<br>            -&gt;make(true);<br>        }<br>        return view('companies');<br>    }<br><br>    /**<br>     * Show the form for creating a new resource.<br>     *<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function create()<br>    {<br>        //<br>    }<br><br>    /**<br>     * Store a newly created resource in storage.<br>     *<br>     * @param  \Illuminate\Http\Request  $request<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function store(Request $request)<br>    {<br>        $companyId = $request-&gt;id;<br> <br>        $company   =   Company::updateOrCreate(<br>                    [<br>                     'id' =&gt; $companyId<br>                    ],<br>                    [<br>                    'name' =&gt; $request-&gt;name, <br>                    'email' =&gt; $request-&gt;email,<br>                    'address' =&gt; $request-&gt;address<br>                    ]);    <br>                         <br>        return Response()-&gt;json($company);<br>    }<br><br>    /**<br>     * Display the specified resource.<br>     *<br>     * @param  int  $id<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function show($id)<br>    {<br>        //<br>    }<br><br>    /**<br>     * Show the form for editing the specified resource.<br>     *<br>     * @param  int  $id<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function edit($id)<br>    {<br>        $where = array('id' =&gt; $request-&gt;id);<br>        $company = Company::where($where)-&gt;first();<br><br>        return Response()-&gt;json($company);<br>    }<br><br>    /**<br>     * Update the specified resource in storage.<br>     *<br>     * @param  \Illuminate\Http\Request  $request<br>     * @param  int  $id<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function update(Request $request, $id)<br>    {<br>        //<br>    }<br><br>    /**<br>     * Remove the specified resource from storage.<br>     *<br>     * @param  int  $id<br>     * @return \Illuminate\Http\Response<br>     */<br>    public function destroy($id)<br>    {<br>        $company = Company::where('id','$request-&gt;id')-&gt;delete();<br>        return Response()-&gt;json($company);<br>    }<br>}</pre>



<h1 class="wp-block-heading" id="4f8c">Step 6 — Create Blade Views File</h1>



<p class="wp-block-paragraph" id="f046">Create two blade views file, which is following:</p>



<ul class="wp-block-list"><li>companies.blade.php</li></ul>



<p class="wp-block-paragraph" id="7356">Next go to companies.blade.php file and paste below code</p>



<pre class="wp-block-preformatted">&lt;!DOCTYPE html&gt;<br>&lt;html lang="en"&gt;<br>&lt;head&gt;<br>&lt;meta charset="UTF-8"&gt;<br>&lt;title&gt;Laravel 8 AJAX CRUD using DataTable js Tutorial From Scratch - Tutsmake.com&lt;/title&gt;<br>&lt;meta name="csrf-token" content="{{ csrf_token() }}"&gt;<br>&lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" &gt;<br>&lt;script src="https://code.jquery.com/jquery-3.5.1.min.js"&gt;&lt;/script&gt;<br>&lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"&gt;&lt;/script&gt;<br>&lt;link  href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css" rel="stylesheet"&gt;<br>&lt;script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"&gt;&lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;div class="container mt-2"&gt;<br>&lt;div class="row"&gt;<br>&lt;div class="col-lg-12 margin-tb"&gt;<br>&lt;div class="pull-left"&gt;<br>&lt;h2&gt;Laravel 8 Ajax CRUD DataTables Tutorial&lt;/h2&gt;<br>&lt;/div&gt;<br>&lt;div class="pull-right mb-2"&gt;<br>&lt;a class="btn btn-success" onClick="add()" href="javascript:void(0)"&gt; Create Company&lt;/a&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>@if ($message = Session::get('success'))<br>&lt;div class="alert alert-success"&gt;<br>&lt;p&gt;{{ $message }}&lt;/p&gt;<br>&lt;/div&gt;<br>@endif<br>&lt;div class="card-body"&gt;<br>&lt;table class="table table-bordered" id="ajax-crud-datatable"&gt;<br>&lt;thead&gt;<br>&lt;tr&gt;<br>&lt;th&gt;Id&lt;/th&gt;<br>&lt;th&gt;Name&lt;/th&gt;<br>&lt;th&gt;Email&lt;/th&gt;<br>&lt;th&gt;Address&lt;/th&gt;<br>&lt;th&gt;Created at&lt;/th&gt;<br>&lt;th&gt;Action&lt;/th&gt;<br>&lt;/tr&gt;<br>&lt;/thead&gt;<br>&lt;/table&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;!-- boostrap company model --&gt;<br>&lt;div class="modal fade" id="company-modal" aria-hidden="true"&gt;<br>&lt;div class="modal-dialog modal-lg"&gt;<br>&lt;div class="modal-content"&gt;<br>&lt;div class="modal-header"&gt;<br>&lt;h4 class="modal-title" id="CompanyModal"&gt;&lt;/h4&gt;<br>&lt;/div&gt;<br>&lt;div class="modal-body"&gt;<br>&lt;form action="javascript:void(0)" id="CompanyForm" name="CompanyForm" class="form-horizontal" method="POST" enctype="multipart/form-data"&gt;<br>&lt;input type="hidden" name="id" id="id"&gt;<br>&lt;div class="form-group"&gt;<br>&lt;label for="name" class="col-sm-2 control-label"&gt;Company Name&lt;/label&gt;<br>&lt;div class="col-sm-12"&gt;<br>&lt;input type="text" class="form-control" id="name" name="name" placeholder="Enter Company Name" maxlength="50" required=""&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;  <br>&lt;div class="form-group"&gt;<br>&lt;label for="name" class="col-sm-2 control-label"&gt;Company Email&lt;/label&gt;<br>&lt;div class="col-sm-12"&gt;<br>&lt;input type="email" class="form-control" id="email" name="email" placeholder="Enter Company Email" maxlength="50" required=""&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;div class="form-group"&gt;<br>&lt;label class="col-sm-2 control-label"&gt;Company Address&lt;/label&gt;<br>&lt;div class="col-sm-12"&gt;<br>&lt;input type="text" class="form-control" id="address" name="address" placeholder="Enter Company Address" required=""&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;div class="col-sm-offset-2 col-sm-10"&gt;<br>&lt;button type="submit" class="btn btn-primary" id="btn-save"&gt;Save changes<br>&lt;/button&gt;<br>&lt;/div&gt;<br>&lt;/form&gt;<br>&lt;/div&gt;<br>&lt;div class="modal-footer"&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;!-- end bootstrap model --&gt;<br>&lt;/body&gt;<br>&lt;script type="text/javascript"&gt;<br>$(document).ready( function () {<br>$.ajaxSetup({<br>headers: {<br>'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')<br>}<br>});<br>$('#ajax-crud-datatable').DataTable({<br>processing: true,<br>serverSide: true,<br>ajax: "{{ url('ajax-crud-datatable') }}",<br>columns: [<br>{ data: 'id', name: 'id' },<br>{ data: 'name', name: 'name' },<br>{ data: 'email', name: 'email' },<br>{ data: 'address', name: 'address' },<br>{ data: 'created_at', name: 'created_at' },<br>{data: 'action', name: 'action', orderable: false},<br>],<br>order: [[0, 'desc']]<br>});<br>});<br>function add(){<br>$('#CompanyForm').trigger("reset");<br>$('#CompanyModal').html("Add Company");<br>$('#company-modal').modal('show');<br>$('#id').val('');<br>}   <br>function editFunc(id){<br>$.ajax({<br>type:"POST",<br>url: "{{ url('edit-company') }}",<br>data: { id: id },<br>dataType: 'json',<br>success: function(res){<br>$('#CompanyModal').html("Edit Company");<br>$('#company-modal').modal('show');<br>$('#id').val(res.id);<br>$('#name').val(res.name);<br>$('#address').val(res.address);<br>$('#email').val(res.email);<br>}<br>});<br>}  <br>function deleteFunc(id){<br>if (confirm("Delete Record?") == true) {<br>var id = id;<br>// ajax<br>$.ajax({<br>type:"POST",<br>url: "{{ url('delete-company') }}",<br>data: { id: id },<br>dataType: 'json',<br>success: function(res){<br>var oTable = $('#ajax-crud-datatable').dataTable();<br>oTable.fnDraw(false);<br>}<br>});<br>}<br>}<br>$('#CompanyForm').submit(function(e) {<br>e.preventDefault();<br>var formData = new FormData(this);<br>$.ajax({<br>type:'POST',<br>url: "{{ url('store-company')}}",<br>data: formData,<br>cache:false,<br>contentType: false,<br>processData: false,<br>success: (data) =&gt; {<br>$("#company-modal").modal('hide');<br>var oTable = $('#ajax-crud-datatable').dataTable();<br>oTable.fnDraw(false);<br>$("#btn-save").html('Submit');<br>$("#btn-save"). attr("disabled", false);<br>},<br>error: function(data){<br>console.log(data);<br>}<br>});<br>});<br>&lt;/script&gt;<br>&lt;/html&gt;</pre>



<p class="wp-block-paragraph" id="f9f2">Lets go to your browser and run this url</p>



<pre class="wp-block-preformatted">http://127.0.0.1:8000/ajax-crud-datatable</pre>



<p class="wp-block-paragraph" id="a884">Now its open like this and successfully working and store in database as well.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1248/1*hpWdD7q8QCep4Hf3PgYXdw.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/1254/1*DbJaCrwlUyJbqA9MMcg9pw.png" alt=""/></figure>



<p class="wp-block-paragraph" id="2e1b">Thanks <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f64f.png" alt="🙏" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f64f.png" alt="🙏" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-add-data-in-datatable-in-laravel-crud/">How to Add Data in DataTable in Laravel Crud</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-add-data-in-datatable-in-laravel-crud/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Laravel 5.8 CRUD operation with example</title>
		<link>https://www.scmgalaxy.com/tutorials/laravel-5-8-crud-operation-with-example/</link>
					<comments>https://www.scmgalaxy.com/tutorials/laravel-5-8-crud-operation-with-example/#respond</comments>
		
		<dc:creator><![CDATA[Joydeep M]]></dc:creator>
		<pubDate>Thu, 22 Apr 2021 10:40:24 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[crud]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=5946</guid>

					<description><![CDATA[<p>In this tutorial we will learn how we can create a project in CRUD (Create, Read, Update and Delete) operations [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/laravel-5-8-crud-operation-with-example/">Laravel 5.8 CRUD operation with example</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this tutorial we will learn how we can create a project in CRUD (Create, Read, Update and Delete) operations through Laravel. We will get to know how to create, update read and delete in Laravel from Scratch.</p>



<p class="wp-block-paragraph">Initially have to download Laravel 5.8 version. For this you have to go to command prompt, in which first we have go to our folder path in which we want to download Laravel 5.8. After this we have to run &#8220;composer&#8221; command, because all Laravel depository is handled by composer. After run &#8220;composer&#8221; command we have to run following command:</p>



<pre class="wp-block-code"><code>composer create-project laravel/laravel=5.8 crud --prefer-dist</code></pre>



<p class="wp-block-paragraph">After downloading Laravel 5.8, we have to make Mysql database connection from Laravel 5.8.</p>



<p class="wp-block-paragraph">We have to find <strong>.env</strong> file in your Laravel 5.8 folder. Open that file and under we have to define our mysql database before that we have to create a database in our mysql named as &#8216;crud&#8217; and then we have to configure our .env as given below.</p>



<pre class="wp-block-code"><code>DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=crud
DB_USERNAME=root
DB_PASSWORD=</code></pre>



<p class="wp-block-paragraph">After this we have to create migration file in our Laravel folder. For this we have to write following command in your command prompt.</p>



<pre class="wp-block-code"><code>php artisan make:migration create_crud_table --create=crud</code></pre>



<p class="wp-block-paragraph">This command will create migration file in <strong>database/migrations</strong> folder. In this file we have to define table column which we want to create in table. Below we can find migration file in which we have define table column.</p>



<script src="https://gist.github.com/Joydeep-cotocus/ad5e12b87eae012268f2f8e012964010.js"></script>



<p class="wp-block-paragraph">Now we want to migrate this table definition from this Laravel application to mysql database. For this we have write following command in command prompt. This command will make crud table in mysql database for perform CRUD operation from Laravel 5.8 application.</p>



<pre class="wp-block-code"><code>php artisan migrate</code></pre>



<p class="wp-block-paragraph">Now we have to create model for our database which is used for operations in controller class. To create a model we will run the command given below.</p>



<pre class="wp-block-code"><code>php artisan make:model Crud -m</code></pre>



<p class="wp-block-paragraph">This command will make <strong>Crud.php</strong> model file in <strong>app</strong> folder. In this file we have to define table column name which we can see below source code of <strong>Crud.php</strong> file.</p>



<script src="https://gist.github.com/Joydeep-cotocus/c63d2ae41561fd2a4d1c8600488176ac.js"></script>



<p class="wp-block-paragraph">Now we have to create Laravel 5.8 crud controller. For this we have to go to command prompt and under this we have write following command.</p>



<pre class="wp-block-code"><code>php artisan make:controller CrudsController --resource</code></pre>



<p class="wp-block-paragraph">This command will make <strong>CrudsController.php</strong> file in <strong>app/Http/Controllers</strong> folder. Once we open this file, we can find all predefine method for do CRUD operation in this controller file. We have to just add code for doing particular operation. Below we can find CRUD controller file code.</p>



<script src="https://gist.github.com/Joydeep-cotocus/258c028f8542366e7033dfb255de2942.js"></script>



<p class="wp-block-paragraph">Now we have to set route of all CrudsController class method. For this we have to open to <strong>routes/web.php</strong> file. In this file we have to write following code for set route of all method.</p>



<pre class="wp-block-code"><code>Route::resource('crud','CrudsController');</code></pre>



<p class="wp-block-paragraph">Now in this step we have to set data in view file which has been store under <strong>resources/views</strong> folder, because this view file has received data from controller method, so here we have to set data in view file. Below we can find all view file which has been used in Crud application, and we can also find how data has been set and how to make form in Laravel 5.8 view file.</p>



<script src="https://gist.github.com/Joydeep-cotocus/79ca56789743fb0015a265e02e4354be.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/910a09d56d35b0dd66e8370c174ee7c6.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/e1db80b1febd9aa341cc74a8588c442b.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/9d83e06f63e2bc7a61a52b811b58cf90.js"></script>



<script src="https://gist.github.com/Joydeep-cotocus/81b3c52ba18174c8962b986f4c5465af.js"></script>



<p class="wp-block-paragraph">Now we can run the Laravel 5.8 Crud application, for this we have to go to command prompt, and write following command.</p>



<pre class="wp-block-code"><code>php artisan serve</code></pre>



<p class="wp-block-paragraph">For reference you can see the video given below:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe  id="_ytid_52458"  width="640" height="360"  data-origwidth="640" data-origheight="360" src="https://www.youtube.com/embed/3Dt34Tb2QIA?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;" class="__youtube_prefs__  epyt-is-override  no-lazyload" title="YouTube player"  allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen data-no-lazy="1" data-skipgform_ajax_framebjll=""></iframe>
</div></figure>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/laravel-5-8-crud-operation-with-example/">Laravel 5.8 CRUD operation with example</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/laravel-5-8-crud-operation-with-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CRUD Operation Prerequisites.</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/#comments</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Sat, 06 Mar 2021 09:29:08 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[crud basics]]></category>
		<category><![CDATA[crud operation prerequisite]]></category>
		<category><![CDATA[crud operations]]></category>
		<category><![CDATA[crud prerequisite]]></category>
		<category><![CDATA[how to crud]]></category>
		<category><![CDATA[operations in crud]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5433</guid>

					<description><![CDATA[<p>Before performing CRUD operations we need to do some of the basic tasks. These includes:- 1. Installing Laravel 2. Creating [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/">CRUD Operation Prerequisites.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Before performing CRUD operations we need to do some of the basic tasks.                                           These includes:-                                                                                                                                    <strong>1. Installing Laravel                                                                                                                                        2. Creating Laravel Project                                                                                                          3. Making Model                                                                                                                               4. Migrating  </strong>                                                                                                                                            After that we are good to go for performing the operation. </p>



<p class="wp-block-paragraph">Laravel the most popular PHP-based framework for creating database-driven apps is based on the MVC (Model-View-Controller) architecture and can be used for easily creating apps for making CRUD (Create, Retrieve, Update, Delete) operations in the database.</p>



<p class="wp-block-paragraph"><strong>1. Installing Laravel</strong>                                                                                                                                                                                               The first and foremost thing we need to have <em>Laravel </em>and <em>composer </em>installed in our system. the command for installation is<br><em><strong>composer global require “laravel/installer=~1.1”</strong></em><br>if this does not works then we could just write<br><em><strong>composer global require “laravel/installer”</strong></em><br>and it would install the file.<br><strong>2. Creating Laravel Project</strong>                                                                                                                                         Then we need to create a project and for this, we need to type<br><strong><em>composer create-project –prefer-dist laravel/laravel <strong><em>project_name</em></strong></em></strong> <strong><em>“5.8.*”</em></strong><br>If this does not works then we could just write<br><strong><em>composer create-project –prefer-dist laravel/laravel project_name</em></strong><br>it would create a Laravel project named blog (with the latest version).</p>



<p class="wp-block-paragraph"><strong>3. Making Model</strong>  <strong>and Migrating</strong>                                                                                                                        After the project is created we need to create the Model.                                                                     For this we use command.</p>



<p class="wp-block-paragraph"><strong><em>$ php artisan make:model Model_name -mcr</em></strong>  or                                                                                    <strong><em>$ php artisan make:model Model_name -a</em></strong></p>



<p class="wp-block-paragraph">(<strong>Note:-</strong> Model name should begin with a capital letter)                                        Here <strong><em>mcr </em></strong>is (migration controller resources)                                                         we can use m/c/r separately but for better convenience, we use <strong>&#8220;<em>a</em>&#8220;</strong> which can equivalently be used in place of  <strong>&#8220;mcr&#8221;</strong>.</p>



<p class="wp-block-paragraph">After the model is created we need to create the database and attach it. We can instruct for the database creation through codes or we can go to <em>PHPMyAdmin</em>,<em> </em>and there we can create the database and provide the name of the database in the <em>.env</em> file</p>



<div class="wp-block-image is-style-default"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-16.png" alt="" class="wp-image-5435" width="466" height="440" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-16.png 621w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-16-300x283.png 300w" sizes="auto, (max-width: 466px) 100vw, 466px" /></figure></div>



<p class="wp-block-paragraph">After database creation, we need to migrate. Migrations allow to add or drop fields in the database without deleting the records already present.                          for this we use <strong><em>$ php artisan migrate</em></strong>                                                                                                    We could also refresh migration using                                                                                                                                                                             <strong><em>$</em></strong> <strong><em>php artisan migrate:refresh</em></strong></p>



<div class="wp-block-image is-style-default"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-17.png" alt="" class="wp-image-5438" width="426" height="269" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-17.png 568w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-17-300x189.png 300w" sizes="auto, (max-width: 426px) 100vw, 426px" /></figure></div>



<p class="wp-block-paragraph">All the prerequisites to perform CRUD operations are completed and are ready to go. Now we can move to views to create the Html page and perform desired CRUD operations.  </p>



<p class="wp-block-paragraph">For CRUD Operation Detailed Explanation with Example. <a href="https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/" data-type="URL" data-id="https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/">https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/</a></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/">CRUD Operation Prerequisites.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
