I'm using Laravel 5.6
My model is normal
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MyTable extends Model
{
protected $table = 'myTable';
public $timestamps = false;
}
I'm trying to make a simple query where it is to bring 8 records
I'm using it like this:
public function getDevice( Request $request ){
$ip = $request->input('ip');
$table = MyTable::where('description', $ip );
echo "<pre>";
print_r($table );
echo "</pre>";
/*
return response()->json($table);
*/
}
But it's crashing and it's not bringing the result
Consider the table
id | description| status |
1 | 1 | 0 |
2 | 1 | 1 |
3 | 1 | 0 |
4 | 1 | 1 |
But if I use it like this
$query DB::select('SELECT * FROM myTable WHERE description = ?', [1]);
or if you bring only one
$table = MyTable::find(1);
$table = MyTable::all();
It works