Feature Ideas

Laravel 8.x Custom Pagination Example Tutorial

 Step 1: CreatePagination Template

As we are going to use laravel custom pagination template, that's why run below command to have it.

php artisan vendor:publish --tag=laravel-pagination
PHP

 

After running above command run you will get new folder "pagination" on views files(resources/views/vendor). In pagination folder you will get following files by default:

  • default.blade.php
  • bootstrap-4.blade.php
  • simple-bootstrap-4.blade.php
  • simple-default.blade.php
  • semantic-ui.blade.php 

 

But we are going to use our own custom pagination template. We don't use any of the above template. 

 

Step 2: Add Route

Now we need routes to see our pagination page. So create this below route and create some dummy data of users.

routes/web.php

Route::get('/', 'TestController@index');
PHP

  

Step 3: Add Controller 

Ok, now we have to add new controller method "index()" in your TestController, so if you haven't created TestController then you can create it and paste this following code.

app/Http/Controllers/TestController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
{
    public function index()
    {
    	$users = \App\User::paginate(7);
    	
        return view('welcome',compact('users'));
    }
}
PHP

 

Step 4: Create Blade File 

Now we need to create our blade file for users view and custom pagination template. So create it with the following path.

resources/views/vendor/pagination/custom.blade.php


@if ($paginator->hasPages())
    <ul class="pager">
       
        @if ($paginator->onFirstPage())
            <li class="disabled"><span>← Previous</span></li>
        @else
            <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">← Previous</a></li>
        @endif


      
        @foreach ($elements as $element)
           
            @if (is_string($element))
                <li class="disabled"><span>{{ $element }}</span></li>
            @endif


           
            @if (is_array($element))
                @foreach ($element as $page => $url)
                    @if ($page == $paginator->currentPage())
                        <li class="active my-active"><span>{{ $page }}</span></li>
                    @else
                        <li><a href="{{ $url }}">{{ $page }}</a></li>
                    @endif
                @endforeach
            @endif
        @endforeach


        
        @if ($paginator->hasMorePages())
            <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">Next →</a></li>
        @else
            <li class="disabled"><span>Next →</span></li>
        @endif
    </ul>
@endif 
HTML

  

At last we have to create welcome.blade.php file and we will use our custom pagination template. So let's create welcome page and put bellow code on it.

resources/views/welcome.blade.php


@extends('layouts.app')
@push('style')
	<style type="text/css">
		.my-active span{
			background-color: #5cb85c !important;
			color: white !important;
			border-color: #5cb85c !important;
		}
	</style>
	<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
@endpush
@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                
                  <table class="table table-stripped">
                  	<thead>
                  		<tr>
                  			<th>No</th>
                  			<th>Name</th>
                  			<th>Email</th>
                  		</tr>
                  	</thead>
                  	<tbody>
                  		@forelse($users as $user)
                  		<tr>
                  			<td>{{ $loop->index + 1 }}</td>
                  			<td>{{ $user->name }}</td>
                  			<td>{{ $user->email }}</td>
                  		</tr>
                  		@empty
                  		<p>No user found!</p>
                  		@endforelse
                  	</tbody>
                  </table>
               {{ $users->links('vendor.pagination.custom') }}
            </div>
        </div>
    </div>
</div>
@endsection
 
HTML
Learn more »

The Multi-talented Wine Bottle

Every time that I throw a wine bottle into the recycling bin I cringe just a little bit. I get that little upcycling angel/devil on my shoulders that say, Wait don’t throw me in the recycling bin, upcycle me, you know I can become a candle holder, a vase, a planter, a terrarium… and at the risk of becoming a hoarder I rinse out the bottle and stash it with my other vases until it’s project time. Now that the cupboard is filling up I figure it’s time to actually *do* something with these bottles and so I’ve put together a little inspiration board. I’m leaning towards taking the bottles to a glass cutter to makes some tumbler glasses.
I hope that you also find it inspiring for when those little angel/devils appear on your shoulders!
Learn more »

Best use of plastic bottle

Try to reuse plastic bottles as many times as possible. If you do not have a use for it that are still good or operational, donate them to a local charity or environmental organization. Ask to see their wish list, you may have something they need. Many items can also be used for other things than what they were first purchase for. Be creative! A plastic bottle can be made into a funnel by cutting off the bottom, liner for a planter or flower pot, bird feeder, container for storing nails, screws, washers and nuts etc... Below are some creative items made of plastic bottles to inspire you.


 
Aid for Watering Plants


As a Boat and Life Jacket 


 As a Cleaning Aid


 Containers


 Flower Vase


 Flowery Pots

Garden Pots 


Magazine and Newspaper Holder


Serve as an Irrigation 

Sub-Irrigated Planter 


Learn more »

Self Watering Tray

Self Watering Tray


This is a quick and easy project to construct a self-watering capillary tray
It’s basically a tray with its own water supply, that you sit your pots in, and it automatically waters them for you. All you have to do is occassionally top up the main water reservoir, that’s all!
They’re great for seedlings, freshly rooted cuttings, and anything else that needs constant moisture.

How Does it Work?

This simple but effective device works by the principle of wicking, as explained below. In this setup, a terracotta pot (with its drain hole sealed) is used as a water reservoir. Beside it sits a plant in a pot. Both are sitting on capillary matting which absorbs water.


  1. The terracotta pot slowly oozes water out onto the capillary matting.
  2. The capillary matting, a synthetic absorbent material, soaks up water like a sponge.
  3. The moist  potting  soil in the plant’s pot wicks up water from the damp capillary matting.

Now, some basic science. A property of water it that it sticks to itself – this property is called cohesion. It’s easy to understand when you consider that if you put two drops of water next to each other and push them together, they become one big drop!
Similarly to the way that small drops of water join up to make a bigger one, what happens here is that the water in the potting mix connects to the water in the capillary mat which connects to the water in the terracotta pot, and all three objects act like one big wick, drawing an even amount of water across themselves, and maintaining it as long as there’s water in the terracotta pot to draw from.
So, when the plant draws up the water in the potting mix or it dries out from evaporation, water will wick back into it to restore the moisture lost, so our plant gets its water supply and stays a happy plant, which is the way we prefer to keep them!
   

Construction Details


1. The first thing you will need is a plastic tray with drainage holes in it to hold the whole thing together.
Pictured below is a seed punnet tray that is used commercially in nurseries. Any plastic tray with drainage will work.



2. The next important piece is the capillary matting. It’s a grey synthetic fabric about 5mm thick that doesn’t rot from constant moisture. You can probably find it at places that sell greenhouse or hydroponic supplies. 
I’m guessing you can most likely use any absorbent material, maybe even newspaper (which will eventually degrade, but who cares, its recyclable), but I haven’t tried it yet, so if you’re keen to experiment, give it a go and send me some feedback!



3. The third component required, a small terracotta pot, the one used here is a 5″ (13cm) wide pot.


 A small terracotta pot, size is not too critical in this application, it just has to hold enough water!

4. Seal the drain hole in the terracotta pot with silicone sealant (or by any other means) so it holds water and does not leak, and allow it to harden.


5. Cut the capillary matting to size so that it fits neatly into the bottom of the plastic tray.


6. When the silicone sealant has dried properly, you’re ready to set the watering treay up. Place the terracotta pot in the centre of the tray. This ensures an even level of moisture all around the tray.
Best to move this setup to its final location at this point, as it may get too heavy or delicate to move, once the water and plants are put in. A sheletered location with part shade or dappled sunlight is recommended as you don’t want your delicate plants exposed to full sun or wind. The water won’t last as long either!


 7. Place as many plants as you want around the terracotta pot.


8. Fill the terracotta pot with water.


9. Water each of the plants so some excess water runs from the bottoms of the pots onto the capillary matting to establish the wicking into the potting soil.


10. All complete, a well watered collection of plants. Now, just top up the terracotta pot and it will do the rest.
If the terracotta pot accidentally runs dry, re-fill it with water and re-water the individual plant pots to re-establish the wicking.


Some Useful Hints & Tips


This can be scaled up in size too without any problems. this is another setup I have which is almost twice as large, approximately 1.5′ x 2′ in size, which has been in place for a few months. It’s located on the east side near a fence where it gets a bit of morning sun, and dappled or indirect light around noon.


This is where I put small seedlings and freshly rooted cuttings to keep them safe from drying out, and to establish them a bit further till they are ready to plant.
This system of watering, which is essentially what is termed “sub-irrigation” (watering plants from the bottom up), also allows seedlings to develop strong root systems, which make them much stronger when they are planted out in the garden later on.

Since the moisture wicks up from the bottom, and the plants roots will grow towards the source of moisture, the seedlings develop a deep, strong and extensive root system. Be careful because they will grow really well, and will set roots into the capillary matting!

You can add a sheet of root control matting over the capillary matting if you want to avoid the plants rooting into it, and the retailers that sell capillary matting also sell the root control mat .
Also, if you really want to give the seedlings and extra boost, you can add a nutrients or fertilizers to the water in the pot. In keeping it all organic, I’d recommend trying things like seaweed extract, worm casting liquid, or compost tea. You’ll be surprised at the accelerated growth rate due to the supply of constant moisture and nutrients!
Learn more »