<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harisu-Ishbah</title>
    <description>The latest articles on DEV Community by Harisu-Ishbah (@harisulishbah).</description>
    <link>https://dev.to/harisulishbah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F831766%2Ffecf303d-9026-4a9a-a4eb-fcb13245acb2.jpeg</url>
      <title>DEV Community: Harisu-Ishbah</title>
      <link>https://dev.to/harisulishbah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harisulishbah"/>
    <language>en</language>
    <item>
      <title>"Return value of Maatwebsite\\Excel\\Sheet::mapArraybleRow() must be of the type array, int returned"</title>
      <dc:creator>Harisu-Ishbah</dc:creator>
      <pubDate>Sun, 20 Mar 2022 23:33:58 +0000</pubDate>
      <link>https://dev.to/harisulishbah/return-value-of-maatwebsiteexcelsheetmaparrayblerow-must-be-of-the-type-array-int-returned-50ob</link>
      <guid>https://dev.to/harisulishbah/return-value-of-maatwebsiteexcelsheetmaparrayblerow-must-be-of-the-type-array-int-returned-50ob</guid>
      <description>&lt;p&gt;Hello, why i get this error?&lt;br&gt;
what's the solution ?&lt;/p&gt;

&lt;p&gt;view (Ajax) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`            $('#export').click(function (e) {
            let rows_selected = tblMassy.column(0).checkboxes.selected();
                        if (rows_selected.length &amp;gt;= 1)  {

                            $.each(rows_selected, function(index, rowId){

                                console.log( "http://localhost:8000/eksportfilter/" + rowId ) ;
                                // location.href= "/eksportfilter/" + rowId;
                                $.ajax({
                                    type:'POST',
                                    url: "http://localhost:8000/eksportfilter/" + rowId,
                                    dataType: "JSON",
                                    success: function (response) {
                                        console.log( response )
                                    }
                                });   
                            });
                                console.log(rows_selected.length);

                                swal("Good job!", "Eksport data successfully!", "success");

                                $('#tblMassy').DataTable().ajax.reload();
                                // location.reload();
                        } else {
                            swal("Failed Export!", "No Data Delected!", "error");
                        }
        });`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;my controller :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;` public function eksportfilter($id)
    {
            $data = [
                'id' =&amp;gt; $id,

                $m_assy = m_assy::find($id)
            ];
            return Excel::download(new TransactionsExportFilter($m_assy), 'users.xlsx');
    }`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maatwebsite Export :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`public function __construct($data)
    {
        $this-&amp;gt;data = $data;
    }


    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return collect($this-&amp;gt;data);
    }

    public function headings(): array
    {
        return [
            'id',
            'assymainharness',
            'assyab',
            'assyab1',
            'assyab2',
            'assyab3',
            'type',
            'assycode',
            'suffixlevel',
            'desccarline',
            'factory',
            'customer',
        ];`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can anyone help me solve this problem ?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to export data to excel with certain criteria in Laravel 8</title>
      <dc:creator>Harisu-Ishbah</dc:creator>
      <pubDate>Fri, 18 Mar 2022 15:32:44 +0000</pubDate>
      <link>https://dev.to/harisulishbah/how-to-export-data-to-excel-with-certain-criteria-in-laravel-8-40</link>
      <guid>https://dev.to/harisulishbah/how-to-export-data-to-excel-with-certain-criteria-in-laravel-8-40</guid>
      <description>&lt;p&gt;I tried to export excel with criteria using ajax,&lt;br&gt;
but always fails when exporting with criteria,&lt;br&gt;
and I always get the error:&lt;br&gt;
The GET method is not supported for this route. Supported methods: POST.&lt;/p&gt;

&lt;p&gt;can anyone help me here?&lt;/p&gt;

&lt;p&gt;here's the code:&lt;/p&gt;

&lt;p&gt;View Code :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`        $(function () {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
           let tblMassy =  $('#tblMassy').DataTable({
           processing: true,
           serverSide : true,
           autoWidth : false,
           pageLength : 10 ,
           "order" : [[ 0, "desc"]],
           ajax : '{{ URL::to('http://localhost:8000/admin/getMassy') }}',

           columnDefs: [
                {   
                    'targets': 0,
                    'checkboxes': true
                }
            ],
                columns : [
                    {data : 'id' , name: 'id'},
                    {data : 'assymainharness' , name: 'assymainharness'},
                    {data : 'assyab' , name: 'assyab'},
                    {data : 'assyab1' , name: 'assyab1'},
                    {data : 'assyab2' , name: 'assyab2'},
                    {data : 'assyab3' , name: 'assyab3'},
                    {data : 'type' , name: 'type'},
                    {data : 'assycode' , name: 'assycode'},
                    {data : 'suffixlevel' , name: 'suffixlevel'},
                    {data : 'desccarline' , name: 'desccarline'},
                    {data : 'factory' , name: 'factory'},
                    {data : 'customer' , name: 'customer'},
                    {data : 'name' , name: 'name'},
                    {data : 'Actions' , name: 'Actions'}
                ]
            });

            $('#export').click(function (e) {
            let rows_selected = tblMassy.column(0).checkboxes.selected();
                        if (rows_selected.length &amp;gt;= 1)  {

                            $.each(rows_selected, function(index, rowId){

                                // console.log( "http://localhost:8000/eksportfilter/" + rowId ) ;
                                // location.href= "/eksportfilter/" + rowId;
                                $.ajax({
                                    type:'POST',
                                    url: "http://localhost:8000/eksportfilter/" + rowId,
                                    dataType: "JSON",
                                    success: function (response) {
                                        console.log( response )
                                    }
                                });   
                            });
                                console.log(rows_selected.length);

                                swal("Good job!", "Eksport data successfully!", "success");

                                $('#tblMassy').DataTable().ajax.reload();
                                // location.reload();
                        } else {
                            swal("Failed Export!", "No Data Delected!", "error");
                        }
        });

            $('.show_confirm').click(function(event) {
                var form =  $(this).closest("form");
                var name = $(this).data("name");
                event.preventDefault();
                swal({
                    title: `Are you sure you want to delete this record?`,
                    text: "If you delete this, it will be gone forever.",
                    icon: "warning",
                    buttons: true,
                    dangerMode: true,
                })
                .then((willDelete) =&amp;gt; {
                    if (willDelete) {
                        // $('#btn_delete_all').click(function (e) {
                            // e.preventDefault();
                        let rows_selected = tblMassy.column(0).checkboxes.selected();
                        console.log( rows_selected.length );
                        if (rows_selected.length &amp;gt;= 1)  {

                            $.each(rows_selected, function(index, rowId){

                                console.log( "http://localhost:8000/admin/deleteAssy/" + rowId ) ;

                                $.ajax({
                                    type: "POST",
                                    url: "http://localhost:8000/admin/deleteAssy/" + rowId ,
                                    dataType: "JSON",
                                    success: function (response) {
                                        console.log( response )
                                    }
                                });
                            });
                                console.log(rows_selected.length);

                                swal("Good job!", "Delete data successfully!", "success");

                                $('#tblMassy').DataTable().ajax.reload();
                                location.reload();
                        } else {
                            swal("Failed    !", "No Data Delected!", "error");
                        }
                        // });
                    }
                });
            });

                   // submit btndelete all

        });
    &amp;lt;/script&amp;gt;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Route :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;` Route::post('eksportfilter/{id}', [MAssyController::class , 'eksportfilter'])-&amp;gt;name('eksportfilter.post');`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Controller :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;` public function eksportfilter($id)
    {
     return (new TransactionsExportFilter($id))-&amp;gt;download('Master-Assy-list-Filter.xlsx');
    }`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maatwebsite\Excel :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`namespace App\Exports;

use App\Models\m_assy;

use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;

class TransactionsExportFilter implements FromQuery, WithHeadings
{
    use Exportable;

    public $id;   //HERE

    public function __construct(string $keyword)
    {
        $this-&amp;gt;id = $keyword;
    }


    /**
    * @return \Illuminate\Support\Collection
    */
    public function query()
    {
        return m_assy::query()-&amp;gt;where('id', 'like', '%' . $this-&amp;gt;id . '%');
    }

    public function headings(): array
    {
        return [
            'id',
            'assymainharness',
            'assyab',
            'assyab1',
            'assyab2',
            'assyab3',
            'type',
            'assycode',
            'suffixlevel',
            'desccarline',
            'factory',
            'customer',
        ];
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>laravel</category>
    </item>
  </channel>
</rss>
