1569745471
I will explain you how to set custom path with pagination, how to appends input parameter with pagination link etc.
We know pagination is a primary requirement of each and every project. So if you are beginner with laravel than you must know how to use pagination in Laravel 6 and what is other function that can use with Laravel 6 pagination.
In this example I will explain you from scratch how to working with Laravel pagination. So let’s follow bellow tutorial for creating simple example of pagination with Laravel 6.
First thing is we put one route in one for list users with pagination. So simple add both routes in your route file.
routes/web.php
Route::get('users', 'UserController@index');
Same things as above for route, here we will add one new method for route. index() will return users with pagination data, so let’s add bellow:
app/Http/Controllers/UserController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$data = User::paginate(10);
return view('users',compact('data'));
}
}
Laravel 6 CRUD Application Tutorial
In this step, you need to create users blade file and put bellow code with links() so it will generate pagination automatically. So let’s put it.
resources/views/users.blade.php
@extends($theme)
@section('content')
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th width="300px;">Action</th>
</tr>
</thead>
<tbody>
@if(!empty($data) && $data->count())
@foreach($data as $key => $value)
<tr>
<td>{{ $value->name }}</td>
<td>
<button class="btn btn-danger">Delete</button>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="10">There are no data.</td>
</tr>
@endif
</tbody>
</table>
{!! $data->links() !!}
@endsection
Now you can run and check this example. it is a very simple and basic example.
If you need advance used of pagination then you can see bellow how to use.
Pagination with appends parameter
{!! $data->appends(['sort' => 'votes'])->links() !!}
Pagination with appends request all parameters
{!! $data->appends(Request::all())->links() !!}
You can also see in advance details from here: Laravel 6 Pagination.
I hope it can help you…
#laravel #php #web-development
1622006340
In this post I will show you pagination example in laravel, as we all know pagination is very common feature in all websites, if we want to display specific number of details or images then we can use pagination.
aravel provide paginate method and it will automatically takes care of setting the proper limit and offset based on the current page being viewed by the user.here i will show you how to use pagination in laravel, So I have try paginate method in laravel.
#pagination example in laravel #laravel #pagination #paginate method #how to use pagination in laravel #pagination in laravel
1597647163
Laravel create thumbnail from image. Here, i will show you how to upload image and create thumbnail of uploaded image in laravel using intervention package.
Also using laravel intervention image thumbnai, you can resize the image size in laravel.
https://www.tutsmake.com/laravel-intervention-image-upload-using-ajax/
#laravel intervention image thumbnail #laravel create thumbnail from image #create thumbnail of image laravel 7/6 #laravel 7. x and 6. x - image upload with create thumbnail image
1595201363
First thing, we will need a table and i am creating products table for this example. So run the following query to create table.
CREATE TABLE `products` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Next, we will need to insert some dummy records in this table that will be deleted.
INSERT INTO `products` (`name`, `description`) VALUES
('Test product 1', 'Product description example1'),
('Test product 2', 'Product description example2'),
('Test product 3', 'Product description example3'),
('Test product 4', 'Product description example4'),
('Test product 5', 'Product description example5');
Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $fillable = [
'name','description'
];
}
Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.
routes/web.php
Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);
#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete
1597559012
in this post, i will show you easy steps for multiple file upload in laravel 7, 6.
As well as how to validate file type, size before uploading to database in laravel.
You can easily upload multiple file with validation in laravel application using the following steps:
https://www.tutsmake.com/laravel-6-multiple-file-upload-with-validation-example/
#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel
1623389100
Today, We will see laravel 8 create custom helper function example, as we all know laravel provides many ready mate function in their framework, but many times we need to require our own customized function to use in our project that time we need to create custom helper function, So, here i am show you custom helper function example in laravel 8.
#laravel 8 create custom helper function example #laravel #custom helper function #how to create custom helper in laravel 8 #laravel helper functions #custom helper functions in laravel