mirror of
https://github.com/10h30/Test-Eloquent-Relationships.git
synced 2026-07-11 18:56:11 +09:00
Task 7 - polymorphic
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Attachment;
|
||||
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$attachments = Attachment::all();
|
||||
|
||||
return view('attachments.index', compact('attachments'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Attachment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['filename', 'attachable_id', 'attachable_type'];
|
||||
|
||||
public function attachable()
|
||||
{
|
||||
// TASK: fill in the code to make it work
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user