PhoeniX5

PhoeniX5

Member Since 6 Months Ago

Experience Points 1,950
Experience Level 1

3,050 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

04 Aug
2 weeks ago

PhoeniX5 left a reply on Laravel Keyup Function Not Working

Really sorry I missed the id, I added attribute id to the text field.

PhoeniX5 started a new conversation Laravel Keyup Function Not Working

I need to get some values from the database after entering a value in a text field, but nothing happens. Here is my code:

<div class="form-group">
    <label>Entrez le numéro de série</label>
    <input type="text" name="n_serie" required="required" class="form-control" />
</div>
<div class="form-group">
    <label>Panne signalée</label>
    <span id="panne"></span>
</div>

$('#n_serie').keyup(function(){
            event.preventDefault();
            var form_data = $(this).serialize();
            $.ajax({
                url:"{{ route('Reparation.getPanne') }}",
                method:"GET",
                data:form_data,
                dataType:"json",
                success:function(data)
                {
                    $('#panne').html(data.success);
                }
            });
        });
24 Jul
4 weeks ago

PhoeniX5 left a reply on How To Add A Required Attribute To A Drop-down Menu With Jquery ?

Thank you for your reply when I use <select> I don't get the same result when I use <li><a href="#">???</a></li>, can you please show me the code of the drop-down menu part ?

PhoeniX5 started a new conversation How To Add A Required Attribute To A Drop-down Menu With Jquery ?

I need to set a drop-down menu required when an option has been selected in a radio button to submit it in a form, here is my code :

View :

<form method="POST" id="form_inspection">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <span id="form_output"></span>            
            <div class="form-group">
                <label>Etat panne</label>
                <br />
                <label class="radio-inline">
                  <input type="radio" name="et_pn" value="n_panne">Pas de panne
                </label>
                <label class="radio-inline">
                  <input type="radio" name="et_pn" value="panne">Panne
                </label>
            </div>
            <div class="form-group">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"
                        id="dropdown-toggle">Choisissez la panne
                        <span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li class="dropdown-header">Phone</li>
                        <li><a href="#">???</a></li>
                        <li class="divider"></li>
                        <li class="dropdown-header">TV</li>
                        <li><a href="#">???</a></li>
                    </ul>
                </div>
            </div>                     
        </form>

    <script>
    $('#form_inspection input').on('change', function() {
          
            if($('input[name=et_pn]:checked', '#form_inspection').val() == 'panne') {
                $("#dropdown-toggle").attr("disabled",false);
                
        //$(".dropdown-menu li a").prop('required',true);

            }
            else {
                $("#dropdown-toggle").attr("disabled",true);                
            }
        });
     </script>
22 Jul
4 weeks ago

PhoeniX5 left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

I managed to solve this by replacing this :

$modele = $request->modele;
            $produit = Produit::find($modele);
            dump($produit->id);
            die();
            if (empty($produit)) {
                exit(json_encode(['message' => "pas trouvé"]));
            }

            $id_produit = $produit->id;

By this :

$produit = DB::table('produits')->where('modele', $request->modele)->first();

And changing both the route method and the ajax method to from POST to GET.

PhoeniX5 left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

Sorry, if I was not clear, I thought this might help to resolve the problem, these errors are the browser console display :

GET:

(Method Not Allowed)

POST:

produit:92 Uncaught TypeError: Cannot read property 'length' of undefined at Object.success (produit:92)

And if I open those in a new tab I get this error which is laravel error display :

"The GET method is not supported for this route. Supported methods: POST."

PhoeniX5 left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

Thank you for your reply, but nothing has been resolved. If you read my whole post, you will see that the get method or the post method did not work and both give me the same error which is the title of the post. I mean the PHP controller processing give the same error for get and post.

PhoeniX5 left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

With the get method I get this error :

POST http://127.0.0.1:8000/Inspection/produit/ns 405 (Method Not Allowed)

With the post method I get this error :

produit:92 Uncaught TypeError: Cannot read property 'length' of undefined
    at Object.success (produit:92)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at z (jquery.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4)

PhoeniX5 left a reply on The GET Method Is Not Supported For This Route. Supported Methods: POST.

$ php artisan route:list
+--------+----------+-----------------------+-----------------------+----------------------------------------------------------+--------------+
| Domain | Method   | URI                   | Name
         | Action
         | Middleware   |
+--------+----------+-----------------------+-----------------------+----------------------------------------------------------+--------------+
|        | GET|HEAD | /                     |
         | Closure
         | web          |
|        | GET|HEAD | Inspection            |
         | App\Http\Controllers\[email protected]  | web          |
|        | POST     | Inspection/produit    |
         | App\Http\Controllers\[email protected]_modele  | web          |
|        | POST     | Inspection/produit/ns | inspection.produit.ns | App\Http\Controllers\[email protected]   | web          |
|        | GET|HEAD | Magasin               |
         | App\Http\Controllers\[email protected] | web          |
|        | GET|HEAD | Produit               |
         | App\Http\Controllers\[email protected]     | web          |
|        | GET|HEAD | Type_produit          |
         | App\Http\Controllers\[email protected]    | web          |
|        | GET|HEAD | Type_produit/fetch    | Type_produit.fetch    | App\Http\Controllers\[email protected]        | web          |
|        | GET|HEAD | api/user              |
         | Closure
         | api,auth:api |
|        | GET|HEAD | login                 |
         | App\Http\Controllers\[email protected]        | web          |
|        | POST     | login/checklogin      |
         | App\Http\Controllers\[email protected]   | web          |
|        | GET|HEAD | login/logout          |
         | App\Http\Controllers\[email protected]       | web          |
|        | GET|HEAD | magasin/ajtqte        | magasin.ajtqte        | App\Http\Controllers\[email protected]       | web          |
|        | GET|HEAD | magasin/getMag        | magasin.getMag        | App\Http\Controllers\[email protected]       | web          |
|        | GET|HEAD | produit/fetchdata     | produit.fetchdata     | App\Http\Controllers\[email protected]    | web          |
|        | GET|HEAD | produit/getPro        | produit.getPro        | App\Http\Controllers\[email protected]       | web          |
|        | GET|HEAD | produit/modifier      | produit.modifier      | App\Http\Controllers\[email protected]     | web          |
|        | GET|HEAD | produit/upd           | produit.upd
         | App\Http\Controllers\[email protected]
         | web          |
|        | GET|HEAD | validate/magasin      | validate.magasin      | App\Http\Controllers\[email protected]      | web          |
|        | GET|HEAD | validate/produit      | validate.produit      | App\Http\Controllers\[email protected]      | web          |
+--------+----------+-----------------------+-----------------------+----------------------------------------------------------+--------------+

PhoeniX5 started a new conversation The GET Method Is Not Supported For This Route. Supported Methods: POST.

I am developing an application where I have to submit a form, with some values of this form, get the corresponding values from other MySQL tables and submit it to a table, the problem is that I keep having this error. Here is my code:

View:

$('#form_inspection').on('submit', function(event){
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"{{ route('inspection.produit.ns') }}",
            method:"post",
            data:form_data,
            dataType:"json",
            success:function(data)
            {
                if(data.error.length > 0)
                {
                    var error_html = '';
                    for(var count = 0; count < data.error.length; count++)
                    {
                        error_html += '<div class="alert alert-danger">'+data.error[count]+'</div>';
                    }
                    $('#form_output').html(error_html);
                }
                else
                {
                    $('#form_output').html(data.success);
                    $('#form_inspection')[0].reset();
                }
            }
        })
    });

Controller :

function inspection(Request $request) {
        $validation = Validator::make($request->all(), [
            'modele'     =>  'min:0',
            'couleur'    =>  'min:0',
            'n_serie'    =>  'min:0',
            //'etat_panne' =>  'min:0',
            //'poste'      =>  'min:0',
        ]);

        $error_array = array();
        $success_output = '';
        if ($validation->fails())
        {
            foreach($validation->messages()->getMessages() as $field_name => $messages)
            {
                $error_array[] = $messages;
            }
        }
        else
        {
            $modele = $request->modele;
            $produit = Produit::find($modele);
            if (empty($produit)) {
                exit(json_encode(['message' => "pas trouvé"]));
            }
           
            $id_produit = $produit->id;
            $ns = new Log_ns([
                'id_produit'    =>  $id_produit,
                'n_s'           =>  $request->get('n_s'),
                'couleur'       =>  $request->get('color'),
                'etat_panne'    =>  $request->get('etat_panne'),
                'panne'         =>  $request->get('panne'),
                'remarque'      =>  $request->get('remarque'),
                'poste'         =>  ('1'),
            ]);
            $ns->save();
            $success_output = '<div class="alert alert-success">Produit ajouté</div>';
        }
        $output = array(
            'error'     =>  $error_array,
            'success'   =>  $success_output
        );
        echo json_encode($output);
    }

Route :

Route::post('Inspection/produit/ns', '[email protected]')->name('inspection.produit.ns');

16 Jul
1 month ago

PhoeniX5 left a reply on How To Populate A Drop Dropdown Menu From Another Drowdown Menu ?

Thank you for your replys, I managed to make a dynamic drop down menu on my own ;)

here is my code :

View :

<form method="POST" id="type_produit">
            <br />
            <div class="container box">
                <br />
                <div class="form-group">
                    <select name="produit" id="produit" class="form-control input-lg dynamic" data-dependent="modele">
                        <option value="">Sélectionner le Produit</option>
                        @foreach($produit_list as $produit)
                        <option value="{{ $produit->produit}}">{{ $produit->produit }}</option>
                        @endforeach
                    </select>
                </div>
                <br />
                <div class="form-group">
                    <select name="modele" id="modele" class="form-control input-lg dynamic" data-dependent="id">
                        <option value="">Sélectionner le modele</option>
                    </select>
                </div>
                <br />
                <div class="form-group">
                    <select name="couleur" id="couleur" class="form-control input-lg">
                        <option value="">Sélectionner la couleur</option>
                    </select>
                </div>
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <br />
            </div>
        </form>


$(document).ready(function() {

            $('.dynamic').change(function(){
                if($(this).val() != '')
                {
                var select = $(this).attr("id");
                var value = $(this).val();
                var dependent = $(this).data('dependent');
                var _token = $('input[name="_token"]').val();
                $.ajax({
                    url:"{{ route('Type_produit.fetch') }}",
                    method:"GET",
                    data:{select:select, value:value, _token:_token, dependent:dependent},
                    success:function(result)
                    {
                    $('#'+dependent).html(result);
                    }
                })
                }
            });

            $('#produit').change(function(){
            $('#modele').val('');
            $('#couleur').val('');
            });

        });

Controller:

function getModele(Request $request)
    {
        $produit_list = DB::table('produits')
            ->groupBy('id')
            ->get();
        return view('Type_produit')->with('produit_list', $produit_list);
    }

    function fetch(Request $request)
       {
        $select = $request->get('select');
        $value = $request->get('value');
        $dependent = $request->get('dependent');
        $data = DB::table('produits')
          ->where($select, $value)
          //->groupBy($dependent)
          ->get();
        $output = '<option value="">Select '.ucfirst($dependent).'</option>';
        foreach($data as $row)
        {
         $output .= '<option value="'.$row->$dependent.'">'.$row->$dependent.'</option>';
        }
        echo $output;
    }

Root :

Route::get('/Type_produit', '[email protected]');

Route::get('Type_produit/fetch', '[email protected]')->name('Type_produit.fetch');`

PhoeniX5 left a reply on How To Populate A Drop Dropdown Menu From Another Drowdown Menu ?

Thank you for your reply, when I try to run this code nothing happens and the md drop down menu is still empty :

$("#md_menu li a").click(function(){
            $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "{{ url('Type_produit/getproduit')}}",
                    data: $('#type_produit_form').serialize(),
                    success: function (data) {
                        if (data.error === 0) {
                            $.each(data.prDropDown, function (key, value) {
                                $('#md_dropdown-toggle').append("<option value='" + key + "' selected ='selected'>" + value + "</option>");
                            });
                        } else {
                            swal('Whoops', data.message, 'warning');
                        }
                    },
            });
        });
14 Jul
1 month ago

PhoeniX5 started a new conversation How To Populate A Drop Dropdown Menu From Another Drowdown Menu ?

I am developing an application where I need to populate a dropdown menu with values related to the value selected in the previous dropdown menu all the values are from MySQL database, how populate the second dropdown menu ?

Here is my code:

View:

<form method="POST" id="">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div class="form-group">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button"
                        data-toggle="dropdown" id="pr_dropdown-toggle">Choisissez le type du produit
                    <span class="caret"></span></button>
                    <ul class="dropdown-menu" id="pr_menu">
                        @if (isset($prDropDown))
                            @foreach($prDropDown as $id => $produit)
                                <li><a href="#" >{{$produit}}</a></li>
                            @endforeach
                        @endif
                    </ul>
                </div>
            </div>
            <div class="form-group">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button"
                        data-toggle="dropdown" id="md_dropdown-toggle">Choisissez le modèle
                        <span class="caret"></span></button>
                    <ul class="dropdown-menu" id="md_menu">

                    </ul>
                </div>
            </div>           
        </form>
    </div>
    <br />

    <script type="text/javascript">
    $(document).ready(function() {
        $("#pr_menu li a").click(function(){
            $('.selectedLi').removeClass('selectedLi');
            $(this).addClass('selectedLi');
            var selText = $(this).text();
            $("#pr_dropdown-toggle").html(selText+
            ' <span class="caret"></span>');
            $("#produit").val(selText);
        });

        $("#md_menu li a").click(function(){
            $('.selectedLi').removeClass('selectedLi');
            $(this).addClass('selectedLi');
            var selText = $(this).text();
            $("md_#dropdown-toggle").html(selText+
            ' <span class="caret"></span>');
            $("#produit").val(selText);
        });

Controller:

public function getElectronics() {
        $prDropDown = Produit::groupBy('produit')->pluck('produit');
        return view('Type_produit', compact('prDropDown'));
    }

Route:

Route::get('Type_produit/getproduit', '[email protected]');
03 Jul
1 month ago

PhoeniX5 left a reply on How To Populate A Dropdown Menu From Database ?

I managed to fill the drop-down menu with the data from the MySQL database.

Here is my code :

View :

<div class="form-group">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button"
                        data-toggle="dropdown" id="dropdown-toggle">Choisissez le type du produit
                        <span class="caret"></span></button>
                    <ul class="dropdown-menu">
                            @if (isset($prDropDown))
                            @foreach($prDropDown as $id => $produit)
                        <li><a href="{{$id }}" >{{$produit}}</a></li>
                        @endforeach
                        @endif
                    </ul>
                </div>
            </div>

Controller :

public function getProducts() {
        $prDropDown = Produit::pluck('produit', 'id');
        return view('Type_produit', compact('prDropDown'));
    }
02 Jul
1 month ago

PhoeniX5 left a reply on How To Populate A Dropdown Menu From Database ?

@TYKUS - Please be yourself and keep doing what you do because it's very useful and it allows me to learn.

PhoeniX5 left a reply on How To Populate A Dropdown Menu From Database ?

@TYKUS - Yes, I need to store the submitted data in MySQL table

PhoeniX5 left a reply on How To Populate A Dropdown Menu From Database ?

@TYKUS - Yes, I do.

<script type="text/javascript">

</script>

PhoeniX5 left a reply on How To Populate A Dropdown Menu From Database ?

@TYKUS - Thank you for your reply, can you please provide me with the working solution code ?

PhoeniX5 left a reply on How To Send Value From Dropdown To The Controller Via Ajax ?

@MVD - Thank you for your reply i managed to do this by adding a hidden field and submitting this field with the selected value from the dropdown menu.

PhoeniX5 started a new conversation How To Populate A Dropdown Menu From Database ?

I need to populate a drop-down menu with MySQL database values and trigger it when you select a value, it populates a second drop-down menu with values related to the value selected in the first drop-down menu. Here is my drop-down menu:

<div class="form-group">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button"
                        data-toggle="dropdown" id="dropdown-toggle">Choisissez le modèle
                        <span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li class="dropdown-header">Phone</li>
                        <li><a href="#">Smartphone</a></li>
                        <li><a href="#">Featurephone</a></li>
                        <li class="divider"></li>
                        <li class="dropdown-header">TV</li>
                        <li><a href="#">SmartTV</a></li>
                        <li><a href="#">BasicTV</a></li>
                        <li><a href="#">Demodulateur</a></li>
                    </ul>
                </div>
            </div>
        </div>
13 Jun
2 months ago

PhoeniX5 left a reply on How To Send Value From Dropdown To The Controller Via Ajax ?

@MVD - Can you pls show me how to get the selected value in the controller like below :

$pr = new Produit([
                    'produit'              =>  $request->get('produit'),
                    'modele'               =>  $request->get('modele'),
                    ...
                ]);
 $pr->save();
12 Jun
2 months ago

PhoeniX5 left a reply on How To Send Value From Dropdown To The Controller Via Ajax ?

@MVD - Thank you for your reply, what I meant is how to submit the selected value from the following dropdown menu :

<div class="form-group">
    <div class="dropdown">
        <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Choisissez le type du prduit<span class="caret"></span></button>
            <ul class="dropdown-menu">
                <li class="dropdown-header">Phone</li>
                <li><a href="#">Smartphone</a></li>
                <li><a href="#">Featurephone</a></li>
                <li class="divider"></li>
                <li class="dropdown-header">TV</li>
                <li><a href="#">SmartTV</a></li>
                <li><a href="#">BasicTV</a></li>
                <li><a href="#">Demodulateur</a></li>
            </ul>
    </div>
</div>

I often have the values of the form fields by assigning a name to each entry but in this case I have 5 entries in a single entry.

PhoeniX5 started a new conversation How To Send Value From Dropdown To The Controller Via Ajax ?

Hello, how to get selected value from this dropdown like an : <input type="text" required="required" name="produit" class="form-control" /> when submiting the form ?

Here is my code :

<div class="form-group">
    <div class="dropdown">
        <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Choisissez le type du prduit<span class="caret"></span></button>
            <ul class="dropdown-menu">
                <li class="dropdown-header">Phone</li>
                <li><a href="#">Smartphone</a></li>
                <li><a href="#">Featurephone</a></li>
                <li class="divider"></li>
                <li class="dropdown-header">TV</li>
                <li><a href="#">SmartTV</a></li>
                <li><a href="#">BasicTV</a></li>
                <li><a href="#">Demodulateur</a></li>
            </ul>
    </div>
</div>







$('#pr_form').on('submit', function(event){
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"{{ route('produit.upd') }}",
            method:"GET",
            data:form_data,
            dataType:"json",
            success:function(data)
            {
                if(data.error.length > 0)
                {
                    var error_html = '';
                    for(var count = 0; count < data.error.length; count++)
                    {
                        error_html += '<div class="alert alert-danger">'+data.error[count]+'</div>';
                    }
                    $('#form_output').html(error_html);
                }
                else
                {
                    $('#form_output').html(data.success);
                    $('#pr_form')[0].reset();
                    $('#pr_table').DataTable().ajax.reload();
                }
            }
        })
    });
11 Jun
2 months ago

PhoeniX5 started a new conversation Problem Whith Multiple Triggers In The Same Function

I am developing an application in which I need to update some MySQL database values using laravel datatables. The problem is that when I perform my function, it does not refresh the table so i have to do it manually!! Here is my code :

$('#qte_form').on('submit', function(event){
        var newqte = parseInt($("#qte_ajt").val()) + parseInt($("#prev_qte").val());
        $("#new_qte").val(newqte);
        console.log($("#new_qte").val());
        event.preventDefault();
        var form_data = $(this).serialize();
        if(confirm("Êtes-vous sûr de cette quantité?"))
        {
            $.ajax({
                url:"{{route('magasin.ajtqte')}}",
                method:"get",
                data:form_data,
                dataType:"json",
                success:function(data)
                {
                    if(data.error.length > 0)
                    {
                        var error_html = '';
                        for(var count = 0; count < data.error.length; count++)
                        {
                            error_html += '<div class="alert alert-danger">'+data.error[count]+'</div>';
                        }
                        $('#form_output').html(error_html);
                    }
                    else//refresh
                    {
                        alert(data);
                        $('#form_output').html(data.success);
                        $('#qte_form')[0].reset();
                        $('#p_table').DataTable().ajax.reload();
                    }
                }
            })
        }
        else
        {
            return false;
        }
    });
09 Jun
2 months ago

PhoeniX5 started a new conversation How To Get A Value In Js From Laravel Datatable Cell ?

I am developing an application where i need to get a value from a datatable cell by a button click then update this value in js

PhoeniX5 left a reply on Too Few Arguments To Function

Thank you for your reply, i found a better way to do this.

28 May
2 months ago

PhoeniX5 left a reply on Too Few Arguments To Function

@SNAPEY - Thank you for your reply, now i am getting this error:

"Action App\Http\Controllers\[email protected] not defined. (View: C:\Users\...\resources\views\edit.blade.php)"

I am trying to access to the function update throught the edit view, how do I define it in web.php file ?

26 May
2 months ago

PhoeniX5 started a new conversation Too Few Arguments To Function

I am developing an application where i need to edit and update view with MySql table but i keep getting this error :

"Too few arguments to function App\Http\Controllers\UtilisateursController::modifier(), 0 passed and exactly 1 expected"

Controller:

function modifier($id) {
        $mag = Produit::find($id);
        return view('edit', compact('edit', 'id'));
    }

    function update(Request $req, $id) {
        $this->validate($req, [
            'produit'               =>   'required',
            'modele'                =>   'required',
            'kit'                   =>   'required',
            'job_number'            =>   'required',
            'couleur'               =>   'required',
            'qte_couleur'           =>   'required',
            'piece_par_carton'      =>   'required',
            'carton_par_pallete'    =>   'required'
        ]);

        $pr = Produit::find($id);
        $pr->produit = $req->get('produit');
        $pr->modele = $req->get('modele');
        $pr->kit = $req->get('kit');
        $pr->job_number = $req->get('job_number');
        $pr->couleur = $req->get('couleur');
        $pr->qte_couleur = $req->get('qte_couleur');
        $pr->piece_par_carton = $req->get('piece_par_carton');
        $pr->carton_par_pallete = $req->get('carton_par_pallete');
        $pr->save();
        return redirect()->route('Produit')->with('success', 'Modifié');
    }

View:

$(document).on('click', '.Modifier', function(){
        var id = $(this).attr('id');
        console.log(id);
        if(confirm("Êtes-vous sûr de vouloir modifier ce produit?"))
        {
            $.ajax({
                url:"{{route('produit.modifier')}}",
                mehtod:"get",
                data:{id:id},
                    success:function(data)
                    {
                        alert(data);
                        $('#pr_table').DataTable().ajax.reload();
                    }
            })
        }
        else
        {
            return false;
        }
    });

edit view:

<div class="row">
        <div class="cold-md-12">
            <br />
            <h3>Modifier</h3>
            <br />
            @if(count($errors) >0)
            <div class="alert alert-danger">
                <ul>
                    @foreach($errors->all() as $error)
                    <li>$error</li>
                    @endforeach
                </ul>
            </div>
            @endif
            <form method="post" action="{{action('[email protected]', '$id')}}">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <input type="hidden" name="_method" value="PATCH">
                <div class="form-group">
                    <label>...

root:

Route::get('produit/modifier', '[email protected]')->name('produit.modifier');
15 May
3 months ago

PhoeniX5 left a reply on DataTables Error

@DEVFREY - This is it:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "yajra/laravel-datatables": "^1.0",
        "yajra/laravel-datatables-oracle": "^7.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

PhoeniX5 left a reply on DataTables Error

@SUJANCSE - Still same error

PhoeniX5 left a reply on DataTables Error

@SUJANCSE - I get this error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - yajra/laravel-datatables 1.0.x-dev requires yajra/laravel-datatables-buttons 4.* -> satisfiable...

PhoeniX5 left a reply on DataTables Error

@DEVFREY - I am getting this error :

[InvalidArgumentException]
  Could not find package yajra/laravel-datatables in a version matching ^9.0

PhoeniX5 left a reply on DataTables Error

@RESPECT - I tried every version from ^1.0 to ^8.0

PhoeniX5 started a new conversation DataTables Error

Hello, I am trying to install DataTables in my laravel app but I keep getting errors while running this command :

composer require yajra/laravel-datatables-oracle:^8.0 or ^1.0

Error:

$ composer require yajra/laravel-datatables-oracle:^8.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove laravel/framework v5.8.10
    - Conclusion: don't install laravel/framework v5.8.10
    - yajra/laravel-datatables-oracle 8.0.x-dev requires illuminate/view 5.4.*|5.5.*|5.6.*|5.7.* -> satisfiable by illuminate/view[5.4.x-dev,...

Installation failed, reverting ./composer.json to its original content.
25 Apr
3 months ago

PhoeniX5 started a new conversation Laravel Error "array_map(): Argument #2 Should Be An Array"

I am developing an application but i keep getting this error:

C:\Users\...\vendor\laravel\framework\src\Illuminate\Validation\ValidationRuleParser.php
        }
 
        return $rules;
    }
 
    /**
     * Explode the explicit rule into an array if necessary.
     *
     * @param  mixed  $rule
     * @return array
     */
    protected function explodeExplicitRule($rule)
    {
        if (is_string($rule)) {
            return explode('|', $rule);
        } elseif (is_object($rule)) {
            return [$this->prepareRule($rule)];
        }
 
        return array_map([$this, 'prepareRule'], $rule);//highlight
    }
 
    /**
     * Prepare the given rule for the Validator.
     *
     * @param  mixed  $rule
     * @return mixed
     */
    protected function prepareRule($rule)
    {
        if ($rule instanceof Closure) {
            $rule = new ClosureValidationRule($rule);
        }
 
        if (! is_object($rule) ||


"array_map(): Argument #2 should be an array"

Here is my code: Controller:

function magasin(Request $request) {
        $validation = Validator::make($request->all(), [
            'article'     =>  $request->get('article'),
            'qte_s'       =>  $request->get('qte_s'),
            //'qte_e'       =>  $request->get('qte_e'),
        ]);

        $error_array = array();
        $success_output = '';
        if ($validation->fails())
        {
            foreach($validation->messages()->getMessages() as $field_name => $messages)
            {
                $error_array[] = $messages;
            }
        }
        else
        {
            $mag = new Magasin([
                'article'     =>  $request->get('article'),
                'qte_s'       =>  $request->get('qte_s'),
                //'qte_e'       =>  $request->get('qte_e')
            ]);
            $mag->save();
            $success_output = '<div class="alert alert-success">Produit ajouté</div>';
        }
        $output = array(
            'error'     =>  $error_array,
            'success'   =>  $success_output
        );
        echo json_encode($output);
    }

View:

<script type="text/javascript">
        $(document).ready(function() {

    $(document).on('click', '#pub', function(){
        $('#magModal').modal('show');
    });

    $('#mag_form').on('submit', function(event){
    event.preventDefault();
    var form_data = $(this).serialize();
    $.ajax({
        url:"{{ route('validate.magasin') }}",
        method:"get",
        data:form_data,
        dataType:"json",
        success:function(data)
        {
            if(data.error.length > 0)
            {
                var error_html = '';
                for(var count = 0; count < data.error.length; count++)
                {
                    error_html += '<div class="alert alert-danger">'+data.error[count]+'</div>';
                }
                $('#form_output').html(error_html);
            }
            else
            {
                $('#form_output').html(data.success);
                $('#mag_form')[0].reset();
            }
        }
    })
    });
});
    </script>
19 Mar
5 months ago

PhoeniX5 started a new conversation 404 Not Found The Resource Requested Could Not Be Found On This Server!

I need to host my Laravel app in the internet so far the only working url is the first one without the controller if I try to access views from controller i get :

404
Not Found
The resource requested could not be found on this server!

Here is my code :

Route::get('/', function(){ //only working url
    return view('Demo.support');
});

Route::get('/support', '[email protected]');//same view file as first but not working

Route::get('/support/postdata', '[email protected]')->name('support.postdata');

Route::get('/support/requete', '[email protected]')->name('support.requete');

Route::get('/support/getetat', '[email protected]')->name('support.getetat');

Route::post('/support/checklogin', '[email protected]');
Route::get('admin/logout', '[email protected]');
Route::get('/admin', '[email protected]');

Route::get('admin/getRequete', '[email protected]')->name('admin.getRequete');

Route::get('admin/reponse', '[email protected]')->name('admin.reponse');

Route::get('admin/fetchdata', '[email protected]')->name('admin.fetchdata');

PhoeniX5 left a reply on Namespace Declaration Statement Has To Be The Very First Statement Or After Any Declare Call In The Script

@MANELGAVALDA - <?php is the first thing in the page, here is a part of code from beginning :

<?php
namespace App\Http\Controllers;

use Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Demo;
use DB;
use Auth;
use Yajra\DataTables\DataTables;

class DemoController extends Controller
{
    public $code;
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('demo.support');
    }
...

PhoeniX5 started a new conversation Namespace Declaration Statement Has To Be The Very First Statement Or After Any Declare Call In The Script

I need to host my Laravel app in internet when running it in local server it works without issues but in the internet server it keeps saying :

Namespace declaration statement has to be the very first statement or after any declare call in the script

This is my namespace :

<?php
namespace App\Http\Controllers;

14 Mar
5 months ago

PhoeniX5 left a reply on How To Display Views When Hosting A Laravel Project On Internet ?

@PARDEEPKUMAR - I checked everything seems fine, but i keep getting error HTTP 500.

PhoeniX5 left a reply on How To Display Views When Hosting A Laravel Project On Internet ?

@JLRDW - I need to host my app in a shared server, so I downloaded my app in the server then I imported the database but i have no views, how do I display my views as in a local server (127.0.0.1:8000/support) as (subdomain/support), like in the route file ?

13 Mar
5 months ago

PhoeniX5 started a new conversation How To Display Views When Hosting A Laravel Project On Internet ?

I need to access to my view folder and files when hosting my Laravel app, so far i have access to the index file by doing subdomain/public but i get error 404, so i need to access the views in ressources folder.

This is my route :

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/support', '[email protected]');

Route::get('/support/postdata', '[email protected]')->name('support.postdata');

Route::get('/support/requete', '[email protected]')->name('support.requete');

Route::get('/support/getetat', '[email protected]')->name('support.getetat');

Route::post('/support/checklogin', '[email protected]');
Route::get('support/successlogin', '[email protected]');
Route::get('support/logout', '[email protected]');

Route::get('/admin', '[email protected]');

Route::get('admin/getRequete', '[email protected]')->name('admin.getRequete');

Route::get('admin/reponse', '[email protected]')->name('admin.reponse');

Route::get('admin/fetchdata', '[email protected]')->name('admin.fetchdata');
12 Mar
5 months ago

PhoeniX5 left a reply on How To Use A Custom Form Validator In Laravel ?

@STEREOH - I need to make each field required (*), how to trigger each field for that to display each error message on top of it's specific field instead ?

PhoeniX5 started a new conversation How To Use A Custom Form Validator In Laravel ?

I need to use Laravel validator to show only a single meesage if something wrong because in my case i have a form with 7 fields that are all required, when using Laravel validator on submit it shows an error message for every field, which is 7 messages in total where each message is on top of the other, that's making my view a mess, if this is not possible with Laravel validator, which custom validator should I use and how do I use it ?

View :

$('#demo_form').on('submit', function(event){
        event.preventDefault();    
        var form_data = $(this).serialize();

        $.ajax({
            url:"{{ route('support.postdata') }}",
            method:"get",
            data:form_data,
            dataType:"json",
            success:function(data)
            {
                if(data.error.length > 0)
                {
                    var error_html = '';
                    for(var count = 0; count < data.error.length; count++)
                    {
                        error_html += '<div class="alert alert-danger">'+data.error[count]+'</div>';
                    }
                    $('#form_output').html(error_html);
                } 
                else
                {                            
                    $('#form_output').html(data.success);
                    $('#demo_form')[0].reset();
                    window.location="/support/requete";                    
                }              
            }
        })
    });

Controller :

function postdata(Request $request)
    {
        $validation = Validator::make($request->all(), [
            'nom'                   => 'required|min:3|max:20',
            'prenom'                => 'required|min:3|max:20',
            'reference'             => 'required|min:4|max:20',
            'n_mac'                 => 'required|min:12|max:20',
            'n_serie'               => 'required|min:16|max:32',
            'probleme_survenu'      => 'required|min:10|max:150',
            'plus_infos'            => 'min:0|max:150',
        ]);

        $error_array = array();
        $success_output = '';
        if ($validation->fails())
        {
            foreach($validation->messages()->getMessages() as $field_name => $messages)
            {
                $error_array[] = $messages;
            }
        }
        else
        {   
            $re = $request->get('plus_infos');
            if($re == '')
            {
                $re = 'vide';
            }      
            $support = new Demo([
                'ID_req'                =>  session('code'),
                'nom'               =>  $request->get('nom'),
                'prenom'            =>  $request->get('prenom'),
                'reference'         =>  $request->get('reference'),
                'n_mac'             =>  $request->get('n_mac'),
                'n_serie'           =>  $request->get('n_serie'),
                'probleme_survenu'  =>  $request->get('probleme_survenu'),
                'plus_infos'        =>  $re,
                'reponse'           =>  '',               
            ]);
            $support->save();
            $success_output = '<div class="alert alert-success">Requête envoyée</div>';
        }
        $output = array(
            'error'     =>  $error_array,
            'success'   =>  $success_output
        );
        echo json_encode($output);        
    }
07 Mar
5 months ago

PhoeniX5 left a reply on Laravel Wrong Data Display From MySql Table !

@MUNAZZIL - Thank you for your reply, i updated my code please take a look.

PhoeniX5 left a reply on Laravel Wrong Data Display From MySql Table !

@MUNAZZIL - Thank you for your reply, but the field name is 'id' in MySql table, i updated my code.

PhoeniX5 left a reply on Laravel Wrong Data Display From MySql Table !

@TGRASSMEE - I mean I am getting random numbers display in field id that does not correspond to what i have in my MySql table, the other fields are correct.