I have two databases named users and calls.
Calls table
<?php
public function up()
{
Schema::create('calls', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable();
$table->timestamps();
$table->text('terminal_id', 20);
$table->text('terminal_name', 100);
$table->text('fault_description');
$table->string('call_status', 10)->default('New call');
$table->string('pending_on', 20)->nullable();
$table->text('closed_on', 20)->nullable();
$table->text('closed_by', 50)->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
CallsController
public function index()
{
$calls = Call::orderBy('created_at', 'desc')->get();
return view('pages.newCall')->with('calls', $calls);
}
public function viewCall($id) {
$calls = Call::find($id);
return view('pages.viewCall')->with('calls', $calls);
}
Currently, the CallsController is returning all the rows in the calls table, but I want it to return only the rows that have the property 'New call' on the call_status column in the calls table. How do I do this from the CallsController?
$calls = Call::where('call_status', 'New call')->orderBy('created_at', 'desc')->get();call_statusdoes not have any value, how do I reference it in$calls = Call::where('call_status', 'New call')->orderBy('created_at', 'desc')->get();i.e removing the valueNew callwhere('call_status', '!=', 'New call')to get the rows where the call status is not New call.