fix: resolve cat_name exception and correct model relationships
This commit is contained in:
@@ -502,7 +502,8 @@ class PagesController extends Controller
|
|||||||
public function awardcategories(Request $category_req)
|
public function awardcategories(Request $category_req)
|
||||||
{
|
{
|
||||||
if (!$category_req->category) {
|
if (!$category_req->category) {
|
||||||
return view('awardcategories');
|
$categories = CarShowCategory::all();
|
||||||
|
return view('awardcategories', ['categories' => $categories]);
|
||||||
}
|
}
|
||||||
$category = $category_req->category;
|
$category = $category_req->category;
|
||||||
if ($category_req->has('vehtype')) {
|
if ($category_req->has('vehtype')) {
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class CarShowWinner extends Model
|
|||||||
|
|
||||||
public function awardVehicle()
|
public function awardVehicle()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Vehicles', 'id', 'vehicle');
|
return $this->belongsTo('App\Models\Vehicles', 'vehicle', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function awardCategory()
|
public function awardCategory()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\CarShowCategory', 'id', 'category');
|
return $this->belongsTo('App\Models\CarShowCategory', 'category', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ class VehicleScores extends Model
|
|||||||
|
|
||||||
public function scoredVehicle()
|
public function scoredVehicle()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Vehicles', 'id', 'vehicle');
|
return $this->belongsTo('App\Models\Vehicles', 'vehicle', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($categories as $category)
|
@foreach($categories as $category)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $category->cat_name }}</td>
|
<td>{{ $category->category_name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -21,16 +21,14 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Vehicle Name</th>
|
<th>Vehicle Name</th>
|
||||||
<th>Judge</th>
|
<th>Total Score</th>
|
||||||
<th>Score</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($scores_results as $score)
|
@foreach($scores_results as $score)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $score->vehicles->make }} {{ $score->vehicles->model }}</td>
|
<td>{{ $score->scoredVehicle->make }} {{ $score->scoredVehicle->model }}</td>
|
||||||
<td>{{ $score->judges->judge_name }}</td>
|
<td>{{ $score->totalscore }}</td>
|
||||||
<td>{{ $score->score }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($winners as $winner)
|
@foreach($winners as $winner)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $winner->awardCategory->cat_name }}</td>
|
<td>{{ $winner->awardCategory->category_name }}</td>
|
||||||
<td>{{ $winner->awardVehicle->make }} {{ $winner->awardVehicle->model }}</td>
|
<td>{{ $winner->awardVehicle->make }} {{ $winner->awardVehicle->model }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
Reference in New Issue
Block a user