https://crunchify.com/




http://preview.fancythemes.com/lightly/


@extends('layouts.admin')
@section('title', 'Dashboard')

@section('content')
<style>
.commentList {
    list-style-type: none;
    padding: 0;
}
.commentItem .theAuthor {
    margin-bottom: 5px;
}
.commentItem .theDate {
    font-style: italic;
}
.commentItem {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e2;
}
.flag{
      text-transform: lowercase;
}
.material-switch > input[type="checkbox"] {
  display: none;
}

.material-switch > label {
  cursor: pointer;
  height: 0px;
  position: relative;
  top: 2px;
  width: 40px;
}

.material-switch > label::before {
  background: rgb(0, 0, 0);
  box-shadow: inset 0px 0px 10px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  content: '';
  height: 16px;
  margin-top: -8px;
  position: absolute;
  opacity: 0.3;
  transition: all 0.4s ease-in-out;
  width: 40px;
}

.material-switch > label::after {
  background: rgb(255, 255, 255);
  border-radius: 16px;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
  content: '';
  height: 24px;
  left: -4px;
  margin-top: -8px;
  position: absolute;
  top: -4px;
  transition: all 0.3s ease-in-out;
  width: 24px;
}

.material-switch > input[type="checkbox"]:checked + label::before {
  background: inherit;
  opacity: 0.5;
}

.material-switch > input[type="checkbox"]:checked + label::after {
  background: inherit;
  left: 20px;
}
.action-edit{
    display: inline-block;
    margin: 2px;
}

.comment_status
{
    -webkit-appearance: menulist-button !important;
    width: 7%;
    display: inline-block;
}
</style>
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
    @endif
            <div class="row">
                <h2>#{{$suggestions->id}}-{{$suggestions->suggestion_title}} <span id="my_status_code" class="statuslabel {{$suggestions->scolor}}" data-toggle="tooltip" title="{{$suggestions->stooltips}}">{{$suggestions->name}}</span></h2>
            </div>
            <div class="page-bx">
                <div class="ticket-sidebar">
                    <div class="row">
                        <div class="col-lg-6 col-sm-6">
                            <ul>
                                <li><strong>ID</strong>: #{{$suggestions->id}}</li>
                                <li><strong>Suggested by</strong>: {{$suggestions->suggestor_name}}</li>
                                <li><strong>Email</strong>: {{$suggestions->suggestor_email}}</li>
                                <li><strong>Ip</strong>:  <img src="{{URL::to('/')}}/admin/flags/blank.gif" class="flag flag-{{strtolower(json_decode($suggestions->ip_logs)->countryCode ?? 'in')}}" alt="{{json_decode($suggestions->ip_logs)->regionName ?? 'in'}}" /> ({{json_decode($suggestions->ip_logs)->regionName ?? 'India'}}) {{$suggestions->suggestor_ip}}</li>                           
                                 <li class="item-container"><strong>Status</strong>:
                                <label class="name" style="display:inline-block;"><span><span id="dynemic_status_code" class="statuslabel {{$suggestions->scolor}}" data-toggle="tooltip" title="{{$suggestions->stooltips}}">{{$suggestions->name}}</span></span> &nbsp;</label>
                                <select name="sp_main_status" id='sp_main_status' class='com_text' style="display: none;">
                                    @foreach ($statuses as $status)
                                        <option value="{{ $status->name }}" data-id="{{$status->id}}"> {{ $status->name }}</option>
                                    @endforeach
                                </select>
                                <a href="javascript:void(0)" class="edit" style="color:#21a9ec;font-size: 17px;"><span class="fa fa-pencil"></span></a>
                                <a href="javascript:void(0)" class="save" style="display: none;font-size: 20px;"><span class="fa fas fa-check"></span></a>
                                <a href="javascript:void(0)" class="cancel" style="display: none;color:#bd2b1f;font-size: 20px;"><span class="fa fa-remove"></span></a>
                                <input type='hidden' name='suggestions_id_value' value="{{$suggestions->id}}">
                            </li>
                            <li>
                                    <div class="form-group status_email_note" style="display:none;">
                                    <label>Note:</label>
                                    <textarea class="form-control" name="status_email_note" cols="30" id="status_email_note" placeholder="Describe your Send Email Notes"></textarea>
                            </div>
                             </li>   
                            </ul>

                        </div>
                        <div class="col-lg-6 col-sm-6">
                            <ul>
                                <li><strong>App</strong>: {{$suggestions->cat_name}}</li>
                                <li><strong>Votes</strong>: {{$total_votes}}</li>
                                <li><strong>Comments</strong>: {{$comments_list->count()}}</li>
                                <li><strong>Created</strong>: <time title="{{$suggestions->created_at}}">{{ Carbon\Carbon::parse($suggestions->created_at)->diffForHumans()}}</time></li>
                                <li><strong>Last Update</strong>: <time id="updatedt_at" title="{{$suggestions->updated_at}}">{{ Carbon\Carbon::parse($suggestions->updated_at)->diffForHumans()}}</time></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

             @if(!$comments_list->isEmpty() )
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body">
                            <h3 class="card-title">Comments: {{$comments_list->count()}}</h3>
                            <!-- Create the editor container -->
                            <div class="ticket-commentbar">

                                <ul class="commentList">
                                    @foreach($comments_list as $comments)
                                        <li id="comment{{$comments->id}}" class="commentItem ">
                                            <span class="theDate">{{ \Carbon\Carbon::parse($comments->created_at)->format('d M, Y')}}</span>
                                            <br/>
                                            <span class="theAuthor"><strong>{{$comments->commentor_name}}
                                                </strong>
                                                
                                                @if($comments->type == 1)
                                               <span class="statuslabel sLabelMod">Admin</span>
                                                @endif
                                            </span>
                                            <p>{{$comments->message}}</p>
                                            <div class="action-buttons">
                                            <div class="material-switch action-edit" style="display: none;">
                                                <input id="switch-primary-{{$comments->id}}" value="{{$comments->id}}" name="toggle" type="checkbox" {{ $comments->comment_status === 1 ? 'checked' : '' }}>

                                                <label for="switch-primary-{{$comments->id}}" class="btn-success"></label>
                                            </div>
                                            
                                            <a href="{{ route('admin-comments.edit', $comments->id) }}" class="btn btn-info btn-sm btn-raised" title="Edit Comment"><i class="fa fa-edit
"></i></a>
                <select class="form-control comment_status" name="comment_status" id="{{$comments->id}}">
                    <option value="2" {{ $comments->comment_status == 2 ? 'selected' : '' }}>Pending</option>
                    <option value="1" {{ $comments->comment_status == 1 ? 'selected' : '' }}>Approve</option>
                    <option value="0" {{ $comments->comment_status == 0 ? 'selected' : '' }}>Disapprove</option>
                </select>
                                            </div>
                                        </li>
                                    @endforeach   
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @endif
<!-- Modal -->
<div class="modal fade" id="Modal2" 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">Are you sure?</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="msgsuccess"></div>
                <input type="hidden" name="cmnt_id" id="cmnt_id">
                <input type="hidden" name="stat_id" id="stat_id">

                                <div class="form-group cmnt-msg-txt">
                                 <label>Message:</label>
                                    <textarea class="form-control" name="formcmntText" cols="30" id="formcmntText" placeholder="Describe your Message.."></textarea>
                                </div>
                                <input type="checkbox" name="chk_emailbtn" id="chk_emailbtn" checked> Notify by Email?
            </div> 
            <div class="modal-footer">
                <button type="button" class="btn" data-dismiss="modal">Close</button>&nbsp;
                <button type="button" id="save_change" class="btn">Save changes</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
            <!-- editor -->
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body">
                            <h3 class="card-title">Add a comment</h3>
                            <form id="cForm" class="panel" action="{{ route('admin-suggestions.store') }}?newcomments" method="post">
                                @csrf
                                <div class="form-group">
                                 <label>Message:</label>
                                    <textarea class="form-control" name="formText" cols="30" id="formText" placeholder="Describe your comment"></textarea>
                                </div>
                                <div class="form-group">
                                    <label>Name:</label>
                                    <input class="form-control" name="xyzzy" type="text" id="xyzzy" value="{{ Auth::user()->name }}" placeholder="Your Name">
                                    @if ($errors->has('xyzzy'))
                                        <span class="text-danger">{{ $errors->first('xyzzy') }}</span>
                                    @endif 
                                </div>
                                <div class="form-group">
                                    <label>Email:</label>
                                    <input class="form-control" name="zyxxy" type="text" id="zyxxy" value="{{ Auth::user()->email }}" placeholder="Your Email">
                                    @if ($errors->has('zyxxy'))
                                        <span class="text-danger">{{ $errors->first('zyxxy') }}</span>
                                    @endif 
                                </div>
                                <div class="form-group email_note" style="display:none;">
                                    <label>Note:</label>
                                    <textarea class="form-control" name="formemailText" cols="30" id="formemailText" placeholder="Describe your Send Email Notes"></textarea>
                                </div>
                                <div class="form-group">
                                    <div class="check-bx">
                                        <label>
                                            <input type="checkbox" class="notify_check" name="default_set" value="1" id="ischeck">
                                            <span></span>
                                            Notify Admins via email
                                        </label>
                                    </div>
                                </div>
                                <input type='hidden' name='suggestions_id' value="{{$suggestions->id}}">
                                <input type='hidden' id="active_suggestor" name='active_suggestor' value="{{$suggestions->suggestor_email}}">
                                <input type='text' name='website' style='display:none'>
                                <input type='text' name='email' style='display:none'>
                                <input type='text' name='url' style='display:none'>            
                                <div class="form-group">                            
                                    <button class="btn" type="submit">Post Comment</button>
                                    <a href="{{ url('admin-suggestions') }}" class="btn">Back</a>
                                </div>       
                            </form>
                        </div>
                    </div>
                </div>
            </div>
@endsection

@section('scripts')
<script src="//ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {


$('select[name=comment_status]').change(function(){
    var get_status=$( this ).val();
    if(get_status != 2)
    {
            var get_comments=$( this ).attr('id');
            $("#Modal2").modal('show');
            $("#stat_id").val(get_status);
            $("#cmnt_id").val(get_comments);
    }
});

$('#chk_emailbtn').change(function(){
   var ckbox = $('#chk_emailbtn');
    if (ckbox.is(':checked')) {
        $('.cmnt-msg-txt').show(500);
    } else {
        $('.cmnt-msg-txt').hide(500);
    }

});

$('#save_change').click(function() {
  //$('#Modal2').modal('hide');
    
    var dataobj = {};
    dataobj.mode = $("#stat_id").val();
    dataobj.comment_id = $("#cmnt_id").val();
    dataobj.email_txt = $("#formcmntText").val();
    dataobj.email_send_status = $("#chk_emailbtn").prop('checked');
    dataobj._token = '{{csrf_token()}}';


    $.ajax({
      type:"POST",
      dataType:"JSON",
      url:"{{ url('/updateCommentStatus') }}",
      data:dataobj,
      success:function(data)
      {
        $(".msgsuccess").html('<div class="alert alert-success msgsuccessdata">'+data.status+'</div>');
            setTimeout(function() {
                $(".msgsuccessdata").hide();
                $('#Modal2').modal('hide');
            }, 3000);
      }
    });
    //$('#Modal2').modal('hide');

});

  $('input[name=toggle]').change(function(){
    var mode= $(this).prop('checked');
    var id=$( this ).val();

        var dataobj = {};
        dataobj.mode = $(this).prop('checked');
        dataobj.comment_id = $( this ).val();
        dataobj._token = '{{csrf_token()}}';

    $.ajax({
      type:"POST",
      dataType:"JSON",
      url:"{{ url('/updateCommentStatus') }}",
      data:dataobj,
      success:function(data)
      {
      }
    });
  });

           $('input.notify_check').change(function(){
            if ($(this).is(':checked')) $('div.email_note').show();
            else $('div.email_note').hide();
        }).change();

        $("#cForm").validate({
            rules: {
                formText: {
                    required: true,
                    minlength: 10
                },
                xyzzy: {
                    required: true
                },
                zyxxy: {
                    required: true
                }
            },
            messages: {
                xyzzy:{
                    required: "Your Name is required"
                },
                zyxxy:{
                    required: "Your Email is required"
                },
                formText: {
                required: "Enter Describe your Comment here in details",
                    minlength: "Minimum Comment length is 10"
                }
            },
            errorPlacement: function(error, element) {
                    error.insertAfter(element);
            },
            submitHandler: function(form) {
                form.submit();
            }
        });

    });

var hash = location.hash;

//$(hash).css({"background-color":"#cfe4f7","padding" : "5px"});
    </script>
<script>
$("#time_durations").hide();
$("#sp_status").on( 'change', function (event) {
    event.preventDefault();
    var appFilter = $("#sp_status option:selected").attr('data-id'); 
    //alert(appFilter);
        if(appFilter == 4 || appFilter == 5)
        {
            $("#time_durations").show();
        }
        else
        {
            $("#time_durations").hide();
        }                   
} );

$("#time_main_durations").hide();
$("#sp_main_status").on( 'change', function (event) {
    event.preventDefault();
    var appFilter = $("#sp_main_status option:selected").attr('data-id');  
    //alert(appFilter);
        if(appFilter == 4 || appFilter == 5)
        {
            $("#time_main_durations").show();
        }
        else
        {
            $("#time_main_durations").hide();
        }                   
} );
    
        $(document).ready(function()
        {

            $('.com_text').click(function()
            {
                var com_text = $(this).attr('id');
            });

            //Edit
            $('.edit').click(function()
            {
                $(".status_email_note").show();
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container'),
                    currentItemLabel = itemWrapper.find('.name').text().trim();

                itemWrapper.find('.name').hide();
                itemWrapper.find('.save,.cancel').show();
                itemWrapper.find('.com_text').val(currentItemLabel);
                itemWrapper.find('.com_text').show();
            });


            //Cancel
            $('.cancel').click(function()
            {
                $(".status_email_note").hide();
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container');

                itemWrapper.find('.name,.edit').show();
                itemWrapper.find('.save').hide();
                itemWrapper.find('.com_text').hide();
                itemWrapper.find('.com_text').val('');
                $("#time_main_durations").hide();

            });


            //Save
            $('.save').click(function()
            {
                $(".status_email_note").hide();
                var itemWrapper = $(this).closest('.item-container');
                var sname = itemWrapper.find('.com_text').val().trim();
                var status_id = itemWrapper.find('.com_text').find(':selected').attr('data-id');
                var dataobj = {};
                // dataobj.sid = $(this).attr('data-id');
                dataobj.status_id = status_id.trim();
                dataobj.sname = sname.trim();
                dataobj.suggestions_id = $("input[name=suggestions_id_value]").val();
                
                dataobj.time_durations = $('#time_main_durations option:selected').val();
                dataobj.user_id = $('#user_ids').val();
                dataobj.status_email_note = $('#status_email_note').val();
                dataobj.active_suggestor = $('#active_suggestor').val();

                dataobj._token = '{{csrf_token()}}';
                 //alert(JSON.stringify(dataobj));
                // Your Ajax Code Here
                // Then run this on success to handle updating
                $.ajax(
                    {
                        type:"POST",
                        dataType:"json",
                        url:"{{ url('/updateStatus') }}",
                        cache: false,
                        data: dataobj,
                        success:function(response)
                        {

                            $(".statuslabel").attr('class','');

                            itemWrapper.find
                            itemWrapper.find('.name,.edit').show();
                            itemWrapper.find('.save,.cancel').hide();
                            itemWrapper.find('.com_text').hide();
                            itemWrapper.find('.com_text').val('');
                            itemWrapper.find('#time_main_durations').val('');
                            $("#time_main_durations").hide();
                            $("#my_status_code").addClass('statuslabel').addClass(response['color'][0].color);
                            $("#my_status_code").html(sname.trim());
                            $("#dynemic_status_code").addClass('statuslabel').addClass(response['color'][0].color);
                            $("#dynemic_status_code").html(sname.trim());
                            

                        }
                    });



            });

        });
    </script>
@stop


========================= 1 ================================
 laravel curl,  curl laravel, cURL Requests with Laravel,php Laravel 5.7 curl header,Laravel 5.7 curl get json


Laravel 5.5 - How To Make cURL HTTP Request Example,
Laravel cURL GET request and request's body,
CURL API CALLS WITH Laravel AND JSON DATA (GET POST PUT DELETE),
php curl get request with parameters,
php curl get json,
php Laravel 5.7 curl get request with parameters example,
php Laravel 5.7 curl get request with headers,
Laravel 5.7 php curl post,
curl put request php Laravel 5.7,
php Laravel 5.7 get json data from api,
php Laravel 5.7 curl header



PHP Laravel CURL HTTP GET POST Request 

<h3>PHP CURL POST & GET Examples</h3>
<b>Laravel CURL HTTP GET Request</b>
[php]
$php_curl = curl_init();

curl_setopt_array($php_curl, array(
    CURLOPT_URL => "https://pakainfo.com",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_TIMEOUT => 30000,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
      // Set Here Your Laravel curl Requesred Headers
        'Content-Type: application/json',
    ),
));
$final_results = curl_exec($php_curl);
$err = curl_error($php_curl);
curl_close($php_curl);

if ($err) {
    echo "Laravel cURL Error #:" . $err;
} else {
    print_r(json_decode($final_results));
}
 [/php]


<b>Laravel CURL HTTP POST Request</b>
<p>Laravel 5.7  Make POST Request Examples(curl in Laravel POST Request)</p>
[php]
// Make Post Fields Array
$products_data = [
    'product_name' => 'Laravel Curl Example Books',
    'product_desc' => 'Laravel 5.7 - How To Make cURL HTTP Request Example',
];

$php_curl = curl_init();

curl_setopt_array($php_curl, array(
    CURLOPT_URL => "https://pakainfo.com",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30000,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => json_encode($products_data),
    CURLOPT_HTTPHEADER => array(
      // Set POST here requred headers
        "accept: */*",
        "accept-language: en-US,en;q=0.8",
        "content-type: application/json",
    ),
));

$final_results = curl_exec($php_curl);
$err = curl_error($php_curl);

curl_close($php_curl);

if ($err) {
    echo "Laravel cURL Error #:" . $err;
} else {
    print_r(json_decode($final_results));
}
[/php]

============================== 2 ================================



guzzle http post laravel example, laravel guzzle http client example, guzzle http get request body example in laravel, laravel guzzlehttp example, guzzle laravel use guzzle http, laravel 5 guzzle 6 example


Laravel Guzzle http client example,
Laravel 5.7 Guzzle http client POST request example,
Laravel PHP guzzle http client GET and POST request example,
cURL Request in Laravel Guzzle http client GET and POST Examples,
Execute a HTTP POST Using Laravel CURL,
Guzzle http client GET and POST request example in Laravel 5.7, 
HTTP GET and POST Methods in PHP

Laravel GET POST PUT DELETE Methods 

<h2>Requests Using Guzzle:</h2>
<b>Laravel Install guzzlehttp/guzzle package</b>
<p>Let's start we shall simple step by step <b>install guzzlehttp/guzzle Laravel package</b>b> after that we can best way to use all the CRUD method Therefor Simple Laravel run bellow command.</p>
[php]
composer require guzzlehttp/guzzle:~6.0
[/php]

<p>Now here We will step by step display you how to HTTP POST Using Laravel CURL run all GET, POST, PUT and DELETE in Laravel listed request you can use following Laravel 5.7 controller method:</p>
<h3>Laravel Guzzle http client example Get Request:</h3>
[php]
public function getAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $api_curl_req = $curl_api_clients->get('https://pakainfo.com');
    $api_results = $api_curl_req->getBody();
    dd($api_results);
}
[/php]

<h3>Laravel 5.7 Guzzle http Post Request:</h3>
[php]
public function postAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts";
    $param_body_data['name'] = "Paka Information";
    $api_curl_req = $curl_api_clients->post($url,  ['body'=>$param_body_data]);
    $api_results = $api_curl_req->send();
    dd($api_results);

}
[/php]

<h3>Execute a HTTP Put Request in Laravel:</h3>
[php]
public function putAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts/1";
    $param_body_data['name'] = "Laravel 5.7 Examples";
    $api_curl_req = $curl_api_clients->put($url,  ['body'=>$param_body_data]);
    $api_results = $api_curl_req->send();
    dd($api_results);
}
[/php]

<h3>Guzzle http Delete Request Example:</h3>
[php]
public function deleteAPIRequest()
{
    $curl_api_clients = new \GuzzleHttp\Client();
    $url = "https://pakainfo.com/api/posts/1";
    $api_curl_req = $curl_api_clients->delete($url);
    $api_results = $api_curl_req->send();
    dd($api_results);

}
[/php]

==========================3================================

Simple Laravel 5.7 Jquery Ajax CRUD(insert update delete) tutorial example with source code,
Laravel 5.7 CRUD (Create Read Update Delete) Tutorial Example,
Ajax CRUD example in Laravel 5.7 application,
Laravel 5.7 Ajax CRUD example without page refresh,
Laravel 5.7 CRUD (Create Read Update Delete) Example from scratch,
Laravel 5.7 MySQL CRUD (Create, Read, Update, Delete) Operations using jQuery



laravel 5.7 crud application, add edit delete in laravel 5.7, crud operation laravel 5.7, laravel 5.7 mysql crud example, laravel 5.7 crud tutorial, insert update delete with laravel 5.7, simple crud application in laravel 5.7


Laravel 5.7 CRUD Insert Update Delete using Jquery Ajax Tutorial example with source code


laravel crud,laravel ajax,crud laravel,laravel 5.7 crud,crud laravel 5.7,crud with laravel 5.7, laravel 5.7 crud example




Simple Laravel 5.7 Jquery Ajax CRUD(insert update delete) tutorial example with source code

<h3>Step : 1 Create articles Table Migration</h3>
<b>Laravel Table Migration</b>
[php]
php artisan make:migration create_Articles_table
[/php]

<p>After run this commandd open articles table mimgration file and add foollowing code. migration file create automatic in database/migrations/ this location.</p>
<b>database/migrations/</b>
[php]
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('article_content');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('articles');
    }
}
[/php]

<p>And then, Laravel CMD to run following command for run migration.</p>
[php]
php artisan migrate
[/php]

<h3>Step : 2 Create articles Table Model</h3>
<p>After that, create Article table model usign by following command.</p>
[php]
php artisan make:demo Article
[/php]

<p>And then, open <b>app/Article.php</b> file and past into it following source code.</p>
<b>app/Article.php</b>
[php]
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    protected $fillable = [
        'title', 'article_content'
    ];
}
[/php]

<h3>Step : 3 Create Laravel Routes</h3>
<p>Next, create following routes in <b>routes/web.php</b> file.</p>
<b>routes/web.php</b>
[php]
Route::get('web-articles', 'ArticleController@webArticles');
Route::resource('articles','ArticleController');
[/php]

<h3>Step : 4 Make Laravel 5.7 Controller</h3>
<p>And then, we need to create ArticleController.php file in app/Http/Controllers/ this path and put into it following source code.</p>
<b>app/Http/Controllers/ArticleController.php</b>
[php]
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Article;

class ArticleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function webArticles()
    {
        return view('web-articles');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $articles = Article::latest()->paginate(5);
        return response()->json($articles);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $Article = Article::create($request->all());
        return response()->json($Article);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $Article = Article::find($id)->update($request->all());
        return response()->json($Article);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        Article::find($id)->delete();
        return response()->json(['done']);
    }
}
[/php]

<h3>Step : 5 Create Laravel Blade/View File</h3>
<p>Now, we will make a web-articles.blade.php file in resources/views/ folder. and then simply put into it following source code. here We are using simple bootstrap layout but you can set accourding to you.</p>
<b>resources/views/web-articles.blade.php</b>
[php]
<!DOCTYPE html>
<html>
<head>
  <title>Laravel 5.7 Ajax CRUD Example</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css">
</head>
<body>
  <div class="container">
    <div class="row">
        <div class="col-lg-12 margin-tb">
            <div class="pull-left">
                <h2>Laravel 5.7 Ajax CRUD Example Demo</h2>
            </div>
            <div class="pull-right">
        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-data-component">Create New Article</button>
            </div>
        </div>
    </div>
    <table class="table table-bordered">
      <thead>
          <tr>
        <th>Title</th>
        <th>article_content</th>
        <th width="200px">Action</th>
          </tr>
      </thead>
      <tbody>
      </tbody>
    </table>

    <ul id="pagination" class="pagination-sm"></ul>

    <!-- Create data-component Modal -->
    @include('create')
    <!-- Edit data-component Modal -->
    @include('edit')
  </div>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twbs-pagination/1.3.1/jquery.twbsPagination.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"></script>
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">

  <script type="text/javascript">
    var url = "<?php echo route('articles.index')?>";
  </script>
  <script src="/js/ArticlesAjax.js"></script> 
</body>
</html>
[/php]

<h3>Step : 6 Create JS File</h3>
<p>Next, we need to create ArticlesAjax.js JS file in public/js/ path and put into it following source code.</p>
<b>public/js/ArticlesAjax.js</b>
[php]
var page = 1;
var active_page = 1;
var total_page = 0;
var ajax_data_call = 0;

manageData();

/* manage data list */
function manageData() {
    $.ajax({
        dataType: 'json',
        url: url,
        data: {page:page}
    }).done(function(data) {
      total_page = data.last_page;
      active_page = data.active_page;
      $('#pagination').twbsPagination({
          totalPages: total_page,
          visiblePages: active_page,
          onPageClick: function (event, pageL) {
            page = pageL;
                if(ajax_data_call != 0){
              fetchAllData();
                }
          }
      });
      handleDatalines(data.data);
        ajax_data_call = 1;
    });
}

$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});

/* Get Page Data*/
function fetchAllData() {
  $.ajax({
      dataType: 'json',
      url: url,
      data: {page:page}
  }).done(function(data) {
    handleDatalines(data.data);
  });
}

/* Add new Article table row */
function handleDatalines(data) {
  var data_lines = '';
  $.each( data, function( key, value ) {
      data_lines = data_lines + '<tr>';
      data_lines = data_lines + '<td>'+value.title+'</td>';
      data_lines = data_lines + '<td>'+value.article_content+'</td>';
      data_lines = data_lines + '<td data-id="'+value.id+'">';
        data_lines = data_lines + '<button data-toggle="modal" data-target="#edit-data-component" class="btn btn-primary edit-data-component">Edit</button> ';
        data_lines = data_lines + '<button class="btn btn-danger remove-data-component">Delete</button>';
        data_lines = data_lines + '</td>';
      data_lines = data_lines + '</tr>';
  });
  $("tbody").html(data_lines);
}

/* Create new Article */
$(".crud-submit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#create-data-component").find("form").attr("action");
    var title = $("#create-data-component").find("input[name='title']").val();
    var article_content = $("#create-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'Article',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Created Successfully.', 'Success Alert', {timeOut: 5000});
    });
});

/* Remove Article */
$("body").on("click",".remove-data-component",function() {
    var id = $(this).parent("td").data('id');
    var c_obj = $(this).parents("tr");
    $.ajax({
        dataType: 'json',
        type:'delete',
        url: url + '/' + id,
    }).done(function(data) {
        c_obj.remove();
        toastr.success('Article Deleted Successfully.', 'Success Alert', {timeOut: 5000});
        fetchAllData();
    });
});

/* Edit Article */
$("body").on("click",".edit-data-component",function() {
    var id = $(this).parent("td").data('id');
    var title = $(this).parent("td").prev("td").prev("td").text();
    var article_content = $(this).parent("td").prev("td").text();
    $("#edit-data-component").find("input[name='title']").val(title);
    $("#edit-data-component").find("textarea[name='article_content']").val(article_content);
    $("#edit-data-component").find("form").attr("action",url + '/' + id);
});

/* Updated new Article */
$(".crud-submit-edit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#edit-data-component").find("form").attr("action");
    var title = $("#edit-data-component").find("input[name='title']").val();
    var article_content = $("#edit-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'PUT',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Updated Successfully.', 'Success Alert', {timeOut: 5000});
    });
}); 

[/php]

<p>Last I am ready to Laravel Project run our example Therefor run bellow command ro quick run:</p>
<b>Laravel 5.7 run our example</b>
[php]
php artisan serve
[/php]

<b>Finnally Step We can open bellow simple URL on your Browsers run:</b>
[php]
http://localhost:8000/web-articles
[/php]

======================================== 4 ===========================



laravel redirect with data array,
laravel redirect with success message,
laravel redirect with variable,
laravel redirect to previous page,
laravel redirect with post data,
laravel redirect 301,
laravel redirect not working,
laravel redirect without return,
Laravel Page Redirect after X seconds wait,

Laravel Redirect,Redirect in Laravel,HTTP Redirects Laravel,laravel redirect with data array,Laravel Redirections

Laravel Redirect To Another URL / Web Page Script Example,
Laravel Redirect to URL After Form Submission,
Laravel 5.7 Redirect Based On Referrer Or IP Address
how to redirect from one page to another in Laravel 5.7

Laravel Redirect Tutorial Example From Scratch

<h3>Simple Laravel Page Redirect</h3>
[php]
return redirect('homepage');
[/php]
<p>Redirects to http://www.pakainfo.com/homepage</p>

[php]
return redirect('auth/login');
[/php]
<p>Redirects to www.pakainfo.com/auth/login</p>

[php]
return redirect('');
[/php]
<p>Redirects to the main page – www.pakainfo.com</p>

<h3>Chaining Methods and Redirecting Back</h3>
<p>laravel redirect to previous page</p>
[php]
return redirect()->back();
[/php]

<h3>Laravel Redirect with Data</h3>
[php]
return redirect()->back()->with('error', 'Sorry, Something went wrong contact us(Pakainfo.com).');
[/php]

<b>Reminder: Session Flash Data</b>
<p>laravel redirect with success/Error message and laravel redirect with variable</p>
[php]
//laravel redirect with post data
return redirect()->back()->with('error', 'Something went wrong.')->with('order_value', $value);

//use arrays
$parameters = ['error' => 'Something went wrong.', 'order_value' => $value];
return redirect()->back()->with($parameters);

using withInput()
return redirect()->back()->withInput();
[/php]

<h3>Laravel Redirect to a Route</h3>
<b>app/Http/routes.php</b>
<p>laravel redirect with data array using Route</p>
[php]
get('products', ['as' => 'products_list', 'uses' => 'ProductsController@index']);
[/php]

<b>app/Http/Controllers/ProductController.php</b>
[php]
return redirect()->route('products');
[/php]

<b>app/Http/routes.php:</b>
[php]
get('product/{id}', ['as' => 'product_view', 'uses' => 'ProductsController@show']);
[/php]

<b>app/Http/Controllers/ProductController.php</b>
[php]
return redirect()->route('product_view', 1);
[/php]

<b>app/Http/routes.php:</b>
[php]
get('product/{category}/{id}', ['as' => 'product_view', 'uses' => 'ProductsController@show']);
[/php]

<b>app/Http/Controllers/ProductController.php</b>
[php]
return redirect()->route('product_view', [692, 1]);

//with parameters
return redirect()->route('product_view', ['category'=>692, 'id'=>1]);
[/php]

<h3>Laravel Redirect to a Controller Action</h3>
[php]
return redirect()->action('App\Http\Controllers\ProductsController@index');

//with arguments
return redirect()->action('App\Http\Controllers\ProductsController@show', [1]);
[/php]


============================= 5 ======================================

