Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function up()
- {
- Schema::create('contracts', function (Blueprint $table) {
- $table->increments('id');
- $table->string('java', 191)->nullable();
- $table->unsignedInteger('method_payment');
- $table->integer('kpi_dni')->nullable();
- $table->integer('kpi_ruc')->nullable();
- $table->integer('kpi_pos')->nullable();
- $table->integer('kpi_out')->nullable();
- public function up()
- {
- Schema::create('clients', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->unsignedInteger('document_user')->default(1);
- $table->string('document')->unique();
- $table->string('phone')->nullable();
- $table->string('address')->nullable();
- $table->string('email')->nullable();
- $table->timestamps();
- $table->foreign('document_user')
- ->references('id')->on('document_users')
- ->onUpdate('cascade')
- ->onDelete('cascade');
- });
- }
- public function up()
- {
- Schema::create('contract_client', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('client_id')->unsigned();
- $table->integer('contract_id')->unsigned();
- $table->timestamps();
- });
- }
- class Contract extends Model
- public function clients()
- {
- return $this
- ->belongsToMany('AppClient')
- ->withTimestamps();
- }
- class Client extends Model{
- public function contracts()
- {
- return $this
- ->belongsToMany('AppContract')
- ->withTimestamps();
- }
- class ContractClient extends Model{
- protected $table='contract_client';
- protected $fillable = [
- 'contract_id', 'client_id'
- ];
- public function contract(){
- return $this->belongsToMany('AppContract', 'id', 'contract_id');
- }
- public function client(){
- return $this->belongsToMany('AppClient', 'id', 'client_id');
- }
- @foreach ($contracts as $contract)
- <tr>
- <td>{{$contract->clients()->get()}}</td>
Add Comment
Please, Sign In to add comment