you have error in your syntax.
Career::where($this->posting, '<=', $this->today) ->where($this->closing, '<=', $this->today)->get();
here 1st argument is column name.
where('column_name', '<=', $this->today)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to populate my table with data if today is between posting date and closing date.
public function mount(Career $career)
{
$this->today = Carbon::now();
$this->posting = Carbon::parse($career->posting_date);
$this->closing = Carbon::parse($career->closing_date);
$this->career = Career::where($this->posting, '<=', $this->today) ->where($this->closing, '<=', $this->today)->get();
$this->sortBy = 'id';
$this->sortDirection = 'asc';
$this->perPage = 100;
$this->paginationOptions = config('project.pagination.options');
$this->orderable = (new Career())->orderable;
}
I'm getting this error SQLSTATE[42S22]: Column not found: 1054 Unknown column '2022-05-06 01:10:12' in 'where clause'
also if I try to display $today, $posting and $closing on my blade, they all show date today.
solved this by changing my render
public function render() {
$query = Career::advancedFilter([
's' => $this->search ?: null,
'order_column' => $this->sortBy,
'order_direction' => $this->sortDirection,])
->whereDate('posting_date', '<=', Carbon::now())
->whereDate('closing_date', '>=', Carbon::now());
$careers = $query->paginate($this->perPage);
return view('livewire.career.vacant', compact('careers', 'query'));
}
Please or to participate in this conversation.