riteshsingh1/livewire-crud

Problems with models & fillable with '_'

Opened this issue · 4 comments

I tried to install and work with this package and it throws a lot of errors.

inside the model (services_relation.php)
protected $fillable = ['am_cat_id','service_category'];

Problem 1:
The template wont work as its trying to render

public function render()
    {
        $model = Model::where('am_cat_id', 'like', '%'.$this->search.'%')->orWhere('service_category', 'like', '%'.$this->search.'%')->latest()->paginate($this->paginate);
        return view('livewire.services-relation', [
            'rows'=> $model
        ]);
    }

Which I fixed with

public function render()
    {
        $model = Model::where('am_cat_id', 'like', '%'.$this->search.'%')->orWhere('service_category', 'like', '%'.$this->search.'%')->latest()->paginate($this->paginate);
        return view('livewire.services_relation', [
            'rows'=> $model
        ]);
    }

Problem 2:
Inside the blade file

<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $row->am cat id}}</td>

<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $row->service category}}</td>

Its doing a regular whitespace instead of _

Hope this helps.

Problem 3:
Without timestamps

Inside my model I have

public $timestamps = false;

Error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'order clause' (SQL: select * from `services_relations` where `am_cat_id` like %% or `service_category` like %% order by `created_at` desc limit 10 offset 0)

Thanks,
It will be fixed in next release

rabol commented

I have made a fork and corrected the issues with '_'
https://github.com/rabol/livewire-crud