Skip to content

Commit

Permalink
Example of the error
Browse files Browse the repository at this point in the history
  • Loading branch information
keryja committed Aug 9, 2018
1 parent 268fa19 commit ec15563
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/Http/Controllers/TheController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\TheRelationModel;
use App\TheModel;

class TheController extends Controller
{
public function index()
{
$theModel = TheModel::where(['name' => 'foo'])->first();
abort_if(!$theModel, 404);

$theRelation = $theModel->theRelation()->where(['name' => 'bar'])->first();
abort_if(!$theRelation, 404);
}
}
13 changes: 13 additions & 0 deletions app/TheModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class TheModel extends Model
{
public function theRelation()
{
return $this->hasOne(TheRelationModel::class);
}
}
13 changes: 13 additions & 0 deletions app/TheRelationModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class TheRelationModel extends Model
{
public function theModel()
{
return $this->belongsTo(TheModel::class);
}
}

0 comments on commit ec15563

Please sign in to comment.