0
I would like to use my model to do research on Laravel.
I wish that, if possible, one could explain to 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 it doesn’t 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.
And if you do:
$model = MinhaModel::where( 'campo1', $codigo )->get();
?– Miguel
That’s right. It worked. Thank you very much!
– adventistaam
Can you add answer, please
– adventistaam
Placed below (; obfuscated by the response requirement
– Miguel