laravel limit code example

Example 1: {{Str::limit laravel

{{Str::limit($category->name, 20)}}

if to end 
  
{{Str::limit($category->name, 20, $end='.......')}}
             
or
  
{{\Illuminate\Support\Str::limit($category->name, 20)}}

Example 2: limit laravel

$posts = Post::all()->limit(10)->get();

Example 3: limit 1 1 in laravel query

$products = $art->products->skip(10)->take(10)->get(); //get next 10 rows

Example 4: laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();

Example 5: parametre grouping laravel quert

DB::table('users')
            ->where('name', '=', 'John')
            ->where(function ($query) {
                $query->where('votes', '>', 100)
                      ->orWhere('title', '=', 'Admin');
            })
            ->get();

Example 6: laravel has many limit

public function posts()
{
    return $this->hasMany('App\Models\Post', 'cat_id')->take(4);
}