If you use the naming conventions as stated in the documentation you will prevent a lot of boilerplate code. In this example there is a table named venuereviewreplies , not meeting the Laravel naming conventions. If we rename the table to venue_reviw_replies we can unlock the power of the models and prevent boilerplate code
App\Models;
use Illuminate\Database\Eloquent\Model;
class VenueReviewReply extends Model
{
public $table = 'venuereviewreplies';
public function venuereview()
{
return $this->belongsTo('App\Models\VenueReview', 'venuereview_id');
}
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class VenueReviewReply extends Model
{
public function venuereview()
{
return $this->belongsTo(VenueReview::class);
}
}
LLoadout is your loadout for Laravel, helping you kickstart your development process. Besides this refactoring site we also make some cool packages and video tutorials !
Go to LLoadout on github