I am trying to displaying data on my contractsTable view, the fields from my contracts table are showing, but i am getting this error because i am trying to view data from categories table through my contracts category table which the fk is, let me share my code it would make more sense
my controller code.
....
public function contractTable()
{
$contracts = contract::first();
$cid = $contracts->id;
$categories = category::where('cid', $cid)->with('Contract')->get();
return view('/contractTable',[
'contracts' => $contracts,
with('categories', $categories)
]);
}
my schema
...
Schema::create('contract_categories', function (Blueprint $table){
$table->increments('ccid');
$table->integer('ctid');
$table->integer('cid');
$table->timestamps();
});
Schema::create('contracts', function (Blueprint $table) {
$table->increments('cid');
$table->string('date_serviced');
$table->string('contract_date');
$table->string('location_desc');
$table->enum('rate',array('hourly','per_turn','per_flight','per_push'))->nullable();
$table->string('contract_expiration_date');
$table->string('past_due_penalty');
$table->string('billing_mail_address');
$table->string('billing_email_address');
$table->string('billing_contact_name');
$table->string('billing_contact_phone');
$table->string('account_number');
$table->string('signed');
$table->timestamps();
});
Schema::create('category', function (Blueprint $table) {
$table->increments('ctid');
$table->string('name');
$table->timestamps();
});
my blade file
...
@foreach( $contracts as $contract)
<tr class="text-white">
<td><td>{{ $category->Contract->name }}</td></td>
<td>{{ $company->contract->name }}</td>
<td>{{$contract->date_serviced}}</td>
<td>{{$contract->contract_date}}</td>
<td>{{$contract->location_desc}}</td>
<td>{{$contract->contract_expiration_date}}</td>
<td>{{$contract->past_due_penalty}}</td>
<td>{{$contract->billing_mail_address}}</td>
<td>{{$contract->billing_email_address}}</td>
<td>{{$contract->billing_contact_name}}</td>
<td>{{$contract->billing_contact_phone}}</td>
<td>{{$contract->account_number}}</td>
<td>{{$contract->signed}}</td>
<td><a class='btn btn-primary' href="{{url('update-contract/'. $contract->cid)}}">Update</a></td><br>
<td><a type='submit' name='action' class='btn btn-danger' href="{{url('delete-contract/' . $contract->cid) }}">X</a></td>
@endforeach
</tr>