Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
641 stars 105 forks source link

Problem with Relation, Maximum execution time of 60 seconds exceeded #195

Closed DanielSpindler closed 2 years ago

DanielSpindler commented 2 years ago

Hey, first of all this is my first ticket ever outside of our organization :) Im already sorry for any mistakes.

The Problem in the Code below ::

Everything is Sorting as it should expect the field

<div class="font-semibold text-left w-18">@sortablelink('articleMaster.article_name','Artikelname')</div> it seems to be searching but times out after a while.

ive double checked for the column(names) to be in the database.

Maybe i found a bug, if not i would still be thankful for every help

BlacklistArticle.php

`<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Kyslik\ColumnSortable\Sortable;

class BlacklistArticle extends Model
{
    use Sortable;

    public $table = "blacklist";
    public $timestamps = null;
    public $fillable = ['article_number', 'reason', 'created_at'];
    public $sortable = ['article_number', 'reason', 'created_at'];

    public function articleMaster()
    {
        return $this->hasOne(ArticleMaster::class, 'article_number', 'article_number');
    }
}
`

ArticleMaster.php

`<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Kyslik\ColumnSortable\Sortable;

class ArticleMaster extends Model
{
    use Sortable;

    public $table = "article_master";
    public $timestamps=null;
    public $fillable = ['article_name'];
    public $sortable = ['article_name'];

    public function blacklistArticle()
    {
        return $this->belongsTo(BlacklistArticle::class);
    }
}
`

search-entries-article.blade.php (table header only) (Spaces around the problem to different it from the other (Working) fields)

`<thead class="text-xs font-semibold uppercase text-gray-400 bg-gray-50">
            <tr>
                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-left w-12">@sortablelink('article_number','Artikelnummer')</div>
                </th>

                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-left w-18">@sortablelink('articleMaster.article_name','Artikelname')</div>
                </th>

                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-left w-28">@sortablelink('reason','Grund')</div>
                </th>
                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-left w-1">@sortablelink('created_at','Erstellt am')</div>
                </th>
                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-center w-1">Löschen</div>
                </th>
                <th class="p-2 whitespace-nowrap">
                    <div class="font-semibold text-center w-1">Ändern</div>
                </th>
            </tr>
            </thead>`
DanielSpindler commented 2 years ago

my own fault. Always check the querys in a Timeout... was just a bit to much in the like search.