Skip to content

Extending Media Model #510

Answered by nickwild-999
nickwild-999 asked this question in Q&A
Jul 22, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Thanks Adam, it also worked like that for me when querying ExtendedMedia directly, but I also needed to be able to query from PostController.

I discovered that I needed to add the following to my PostController for it to appear.

  if ($post->image) {
            $post->image->facebook_url = $post->image->facebook_url; 
        }

So my PostController now reads

<?php

namespace App\Http\Controllers;

use App\Models\Post;
use Inertia\Inertia;

class PostController extends Controller
{
    public function index()
    {
        $posts = Post::with('image', 'category')->orderBy('created_at', 'desc')->paginate(5);
        // Optionally, customize or filter the data if needed

        return Ine…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@awcodes
Comment options

@nickwild-999
Comment options

@awcodes
Comment options

@nickwild-999
Comment options

Answer selected by nickwild-999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants