Waldemar's avatar

Title pagination page number

Hello! I need add to title number page! For example

<title>Products Page 2</title>

When i am press to Page 2 Title still Products

0 likes
3 replies
MWDeveloper's avatar

hi @Deamonik we would like to know more details for example what is the name of your model ? what are the variables inside the model and what are you listing on this pages?

Waldemar's avatar

@MWDeveloper

public function index($kind, Request $request)
    {
        $kind = Categories::where('path', $kind)->first();

        if($kind == NULL or $kind->type == 'producer' or $kind == FALSE)
        {
            return abort(404);
        } else {
            $producers = Categories::find($kind->id);
            // $products = Products::where('kind_id', $kind->id)->orderBy('product_order', 'desc')->paginate(12);

            $brands = Input::has('brands') ? Input::get('brands') : null;

            $products = Products::where('kind_id', $kind->id)->where(function($query){
                $brands = Input::has('brands') ? Input::get('brands') : null;
                if(isset($brands)){
                    foreach ($brands as $brand) {
                        $query->orWhere('producer_id', '=', $brand);
                    }
                }
            })->orderBy('product_order', 'desc')->paginate(12);

            return view('categories.index', compact(['products']))
                ->with('category', $kind)
                ->with('producers', $producers)->withInput(Input::all());
        }
    }

HTML

@section('page_title'){{ $category->title }}@stop.

@section('content')
    @include('pagination', ['paginator' => $products])
    @foreach($products as $data)
     {{ $data->title }}
      {{ $data->description }}
      ...
     @endforeach
@stop

Model

class Products extends Model
{
    public $timestamps = false;
    protected $table = 'products';
    protected $fillable = ['title', 'path', 'preview', 'short_description', 'price', 'usd', 'parent_type', 'producer_id'];

    public function value()
    {
        return $this->hasOne('App\Values', 'product_id');
    }

    public function producer()
    {
        return $this->belongsTo('App\Categories', 'producer_id');
    }

    public function kind()
    {
        return $this->belongsTo('App\Categories', 'kind_id');
    }

    public function images()
    {
        return $this->hasMany('App\Images', 'product_id');
    }
}

Please or to participate in this conversation.