Manual pagination from array collection

Here, we will create PaginationController with two method, one for call route and another for creating custom pagination. So let's add controller as like bellow:

 

 Create controller

<?php

 

namespace App\Http\Controllers;

 

use Illuminate\Http\Request;

use Illuminate\Pagination\Paginator;

use Illuminate\Support\Collection;

use Illuminate\Pagination\LengthAwarePaginator;


 

class PaginationController extends Controller

{

    /**

     * The attributes that are mass assignable.

     *

     * @var array

     */

    public function index()

    {

        $myArray = [

            ['id'=>1, 'title'=>'Laravel CRUD'],

            ['id'=>2, 'title'=>'Laravel Ajax CRUD'],

            ['id'=>3, 'title'=>'Laravel CORS Middleware'],

            ['id'=>4, 'title'=>'Laravel Autocomplete'],

            ['id'=>5, 'title'=>'Laravel Image Upload'],

            ['id'=>6, 'title'=>'Laravel Ajax Request'],

            ['id'=>7, 'title'=>'Laravel Multiple Image Upload'],

            ['id'=>8, 'title'=>'Laravel Ckeditor'],

            ['id'=>9, 'title'=>'Laravel Rest API'],

            ['id'=>10, 'title'=>'Laravel Pagination'],

        ];

 

        $data = $this->paginate($myArray);

   

        return view('paginate', compact('data'));

    }

   

    /**

     * The attributes that are mass assignable.

     *

     * @var array

     */

    public function paginate($items, $perPage = 5, $page = null, $options = [])

    {

        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);

        $items = $items instanceof Collection ? $items : Collection::make($items);

        return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);

    }

}

 Create View File



Here, we just need to create blade file to print data. so let's create simple blade file as like bellow:

app/Http/Controllers/PaginationController.php

Read Also: How to Define Fallback Routes in Laravel?

<div class="container">

    <table class="table table-bordered">

        <tr>

            <th>Id</th>

            <th>Title</th>

        </tr>

        @foreach($data as $post)

        <tr>

            <td>{{ $post->id }}</td>

            <td>{{ $post->title }}</td>

        </tr>

        @endforeach

    </table>

</div>

   

{{ $data->links() }}

Now you can run and check.

 

 https://www.itsolutionstuff.com/post/how-to-create-pagination-from-array-in-laravelexample.html

RESIZE REDO LOG ORACLE 10

 


--MELIHAT REDO LOG FILE

select * from V$LOGFILE a, V$LOG b where a.GROUP# = b.GROUP#



--MENAMBAH REDO LOG FILE

ALTER DATABASE ADD LOGFILE ('/opt/oracle/oradata/orcl/redo04.log') SIZE 524288000;

ALTER DATABASE ADD LOGFILE ('/opt/oracle/oradata/orcl/redo05.log') SIZE 524288000;

ALTER DATABASE ADD LOGFILE ('/opt/oracle/oradata/orcl/redo06.log') SIZE 524288000;




--MENGHAPUS REDO LOG FILE

--REDO LOG HANYA DAPAT DI HAPUS KETIKA STATUS INACTIVE // LAKUKAN SWITCH DAN CHECKPOINT

ALTER DATABASE drop LOGFILE GROUP 1;

ALTER DATABASE drop LOGFILE GROUP 2;

ALTER DATABASE drop LOGFILE GROUP 3;


--MEMINDAH REDOLOG FILE

ALTER SYSTEM SWITCH LOGFILE;


--CEKPOIN REDOLOG FILE

alter system checkpoint;

 

 

https://docs.oracle.com/en/database/oracle/oracle-database/19/admin/managing-the-redo-log.html#GUID-6A7FB6CB-AF29-40BC-BDB3-B514C502B2F6

 

https://support.oracle.com/knowledge/Oracle%20Database%20Products/1928361_1.html 

modprobe: ERROR: could not insert 'vboxdrv': Operation not permitted | VIRTUAL BOX

 

 sudo modprobe vboxdrv
    modprobe: ERROR: could not insert 'vboxdrv': Operation not permitted
 

The problem is that the module is not signed and therefore not loaded with the kernel. This will happen if your computer has the SecureBoot mode activated, something very common in modern equipment.

That's why I get this error opening any machine in the virtual box

Kernel driver not installed (rc=-1908)

Do the following steps to sign a driver, and it is loaded as a kernel module, on Ubuntu systems and also on Debian 9:

 

I know that this question is too old, but because there is no accepted answer and none of these answers solved the issue in my case; I am writing how I solved this today:

When running this command, get this error:

$ sudo modprobe vboxdrv
modprobe: ERROR: could not insert 'vboxdrv': Required key not available

The problem is that the module is not signed and therefore not loaded with the kernel. This will happen if your computer has the SecureBoot mode activated, something very common in modern equipment.

That's why I get this error opening any machine in the virtual box

Kernel driver not installed (rc=-1908)

Do the following steps to sign a driver, and it is loaded as a kernel module, on Ubuntu systems and also on Debian 9:

1. Install the mkutil package to be able to do signed.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mokutil

2. generate the signature file:

openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"

3. Then add it to the kernel:

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)

4. Register it for the Secure Boot.

IMPORTANT! That will ask you for a password, put the one you want, you will only have to use it once in the next reboot.

sudo mokutil --import MOK.der

5. Finally, restart the computer. A blue screen will appear with a keyboard wait, press the key that asks you to interrupt the boot.

 



When you are inside the blue screen, select Enroll MOK > Continue > and it will ask you for the password that you have previously entered, you will enter it and you will be informed that the operation has been completed successfully.

Now your operating system will start and you can now use VirtualBox without problem :)

Hope this help someone.

 

 

 

laravel Numeric validation

 

$rules = [
"collectingMyProduct.productId" => 'bail|required|',
"collectingMyProduct.productName" => 'bail|required|',
"collectingMyProduct.signaX" => 'bail|required|digits_between:1,8|',
"collectingMyProduct.signaHari" => 'bail|required|digits_between:1,1|',
"collectingMyProduct.qty" => 'bail|required|digits_between:1,150|',
"collectingMyProduct.productPrice" => 'bail|required|numeric|',
"collectingMyProduct.catatanKhusu" => 'bail|required|',

];

digits_between :min,max

The field under validation must have a length between the given min and max.

numeric

The field under validation must have a numeric value.

max:value

The field under validation must be less than or equal to a maximum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.

min:value

The field under validation must have a minimum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.

How to get or set UNDO_RETENTION parameter - Oracle

I have recently encountered an issue while trying to export the Oracle DB using the expdp command and my database size was huge, therefore I got an error stating that Snapshot is too old

When I researched further I noticed that my UNDO_RETENTION was too less and set to 900 seconds.

This is how I have managed to get or set the value to this parameter in Oracle

 
How to know the current value of UNDO_RETENTION in Oracle

to know the current or configured value of UNDO_RETENTION parameter in Oracle you can use the following SQL query

In order to be able to execute this SQL command, you must have SQL dba privileges or some specific grants to make you an elevated user

SQL> show parameters undo_retention;

NAME                     TYPE     VALUE
---------------------------------- – – ------- – – ----------------------------
undo_retention                 integer     10600

 
How to modify/set this UNDO_RETENTION value in Oracle

to modify or to set this UNDO_RETENTION value in oracle. you can use the following sql query.

Remember that the value of this parameter is mentioned in seconds.

SQL> ALTER SYSTEM SET UNDO_RETENTION = 10600;

System altered.

You can use the previous SQL statement to make sure that the value is changed or not.

Now you can go ahead and re-run the expdp and hopefully it should be fine.

Good luck

 

 https://success.blueyonder.com/s/article/How-to-change-Undo-Retention?language=en_US

https://www.middlewareinventory.com/blog/how-to-get-or-set-undo_retention-parameter-oracle/

Remove “api” Prefix from URL on Laravel

 PHP Laravel Framework makes it easy for us to create a Restful API. We just set the routing in the Routes -> api.php section.

By default we will find that we will be given a url like this http://ourdomain.com/api/[end-point]

This is to distinguish between urls that can be accessed via the web or can only be accessed through api. We want to change it to http://ourdomain.com/[end-point] by removing the “api” prefix.

To change it we just go to the RouteServiceProvider.php file in the app/Providers folder

Then in the mapApiRoutes method function section, we can eliminate the prefix (‘api’)

protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

So that the function becomes as follows

protected function mapApiRoutes()
    {
        Route::middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

If we have changed it, then we can access our API with the URL http://ourdomain.com/[end-point]