I would like to use my model to do research in Laravel.
I would like, if possible, someone could explain me:
I have my model
class minhaModel extends Model
{
protected $table = "minha_model";
public $timestamps = false;
protected $primaryKey = 'ID_CAMPO';
public $incrementing = false;
public $sequence = 'MINHA_SEQUENCIA';
}
What I want to know is why this works:
use Illuminate\Support\Facades\DB;
/* ... */
$model = DB::select( 'SELECT * FROM minha_model WHERE campo1 = ?', array( $codigo ) )
And this does not work here:
use App\HamOcorrenciasAnvisa;
/* ... */
$model = MinhaModel::where( 'campo1', $codigo );
The table is:
id_campo | campo1 | campo2
1 | 123 | 321
2 | 222 | 333
I'm starting with Laravel.