I didn't use the migration files because I have preexisting tables in the database, I want to know how to force laravel to use my composite primary key.if there is any method to override. The composite primary key is (Tel + number_str ) This is my function in the model :
public function saveData(){
$response = new ResponseModel();
//Primary key(Tel + number_str )
$reponse->Tel = '0123456789';//---> the first key
$reponse->number_str = '1'; //---> the second key
$reponse->view = '0';
$reponse->channal = '0';
$reponse->save();
}
when I execute I have this error:
Yajra\Pdo\Oci8\Exceptions\Oci8Exception
Error Code : 904
Error Message : ORA-00904: "ID": invalid identifier Position : 98 Statement : insert into "RESPONSE" ("TEL", "number_str", "view", "channal ") values (:p0, :p1, :p2, :p3) returning "ID" into :p4 Bindings : [0123456789,1,0,0,0]
Laravel ships with the Eloquent ORM, and Eloquent doesn't support composite keys. If you're aiming to override Eloquent methods in order to support them, you'll need to override a lot of core methods to keep everything working properly.
Now, Eloquent isn't the only option to interact with the database. You can still use the Query Builder to perform your operations. But of course without the benefits of an ORM.
DB::table('response')->insert([
'tel' => '0123456789',
'number_str' => 1,
'view' => 0,
'channel' => 0,
]);
DB::table('response')
->where('tel', '0123456789')
->where('number_str', 1)
->get();