VEEINK Plus Tassel Trim Shorts


Warning: Invalid argument supplied for foreach() in /home/veeink.com/public_html/wp-content/plugins/foyar-shadow-wp/includes/shadow/core.php on line 67

VEEINK Plus Tassel Trim Shorts

165474608490BBD1A1768462CA14DBAA560A04958A
Looking for something special in shorts? Check out our VEEINK Plus Tassel Trim Shorts. With a unique tassel trim, these shorts are sure to turn heads. Made from a comfortable stretch fabric, they’re perfect for a day of shopping or a night out on the town. Features: * VEEINK print * Vans style waistband * Elastic waist * Tassel trim around hem * 100% cotton * Machine wash, tumble dry low or line dry * Imported Made with VEEINKQ:

Get first 10 records with Laravel

I want to get a list of records with all relevant information from my DB and then order and paginate the results.
I have code in my ProductController as follows.
public function index($id)
{
$products = Product::with(‘tags’)->where(‘category_id’, $id);
if(isset($_GET[‘limit’])){
$products = Product::paginate($_GET[‘limit’]);
}

return $this->render(‘index’, [
‘products’ => $products,
‘paginator’ => $paginator->create()
]);
}

The results of this code are always displayed even though I specified a LIMIT of 10 on paginater. It still goes over all the records.
My Product Model includes this:
public function tags()
{
return $this->belongsToMany(‘AppProductTag’, ‘tag_product’, ‘product_id’);

}

and the view function:
{!! $products->render()!!}

The records returned from the DB always return all the products with their tags, so there shouldn’t be a problem.

A:

public function tags()
{
return $this->belongsToMany(‘AppProductTag’, ‘tag_product’, ‘product_id’);

}

If you want only limit 10 products, use it this way.
public function tags()
{
$products= $this->get()->toArray(false) ;
$products = array_chunk($products, 10);
return new Response([‘products’=>app(IlluminateSupportCollection::class)->all()->chunk($products)]); // this line may change
}

In this way, $products is array of 10 items

    Leave a Reply