sraines

sraines

Member Since 2 Years Ago

Experience Points
9,300
Total
Experience

700 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
86
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
9,300 XP
Oct
17
3 weeks ago
Activity icon

Replied to Problem Mounting External Drive On Raspberry Pi 4

Got some help on another forum, I just needed to install a package:

sudo apt install ntfs-3g
Activity icon

Started a new Conversation Problem Mounting External Drive On Raspberry Pi 4

I just bought a Raspberry Pi 4 that I've set up as a LAMP stack web server. The OS is Raspbian GNU/Linux 10 (buster). I had an external hard drive that was mounted on my old RPi2b+. I'm trying to mount it on my RPi4 to /mnt/hdd1, but it's not working. When I run sudo mount /dev/sda2 /mnt/hdd1 I get this error in response:

mount: /mnt/hdd1: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error.

I ran this command after some Googling sudo fdisk -l and got this response

Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mmcblk0: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0000c7e5

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192  4615234  4607043  2.2G  e W95 FAT16 (LBA)
/dev/mmcblk0p2      4615235 62521343 57906109 27.6G  5 Extended
/dev/mmcblk0p5      4620288  4685821    65534   32M 83 Linux
/dev/mmcblk0p6      4685824  5210109   524286  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p7      5210112 62521343 57311232 27.3G 83 Linux


Disk /dev/sda: 3.7 TiB, 4000752599040 bytes, 7813969920 sectors
Disk model: My Passport 25E2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 557F352A-C376-42EB-B14C-AE57A8503763

Device      Start        End    Sectors  Size Type
/dev/sda1      34     262177     262144  128M Microsoft reserved
/dev/sda2  264192 7813967871 7813703680  3.7T Microsoft basic data

Partition 1 does not start on physical sector boundary.

And running this command sudo blkid gave me this response

/dev/mmcblk0p1: LABEL_FATBOOT="RECOVERY" LABEL="RECOVERY" UUID="9016-4EF8" TYPE="vfat" PARTUUID="0000c7e5-01"
/dev/mmcblk0p5: LABEL="SETTINGS" UUID="6b1ce41a-4c1a-4e0f-a739-174002f10cdd" TYPE="ext4" PARTUUID="0000c7e5-05"
/dev/mmcblk0p6: LABEL_FATBOOT="boot" LABEL="boot" UUID="04D8-CE80" TYPE="vfat" PARTUUID="0000c7e5-06"
/dev/mmcblk0p7: LABEL="root" UUID="3f266bc3-aedc-47c5-b995-bdb9b72e0740" TYPE="ext4" PARTUUID="0000c7e5-07"
/dev/sda2: LABEL="SMR_BACKUP" UUID="3E30785B30781C59" TYPE="ntfs" PTTYPE="atari" PARTLABEL="Basic data partition" PARTUUID="bd055116-9e2f-48cb-ba38-895a1ffa4a18"
/dev/mmcblk0: PTUUID="0000c7e5" PTTYPE="dos"
/dev/sda1: PARTLABEL="Microsoft reserved partition" PARTUUID="80e4f497-3551-43d0-8cf4-dd105c597780"

I'm kind of out of my depth on this one. Something to do with the way the drive is partitioned I guess? It's a Western Digital if that matters. And I need to be able to use the drive on Windows 7 and up as well if that makes a difference.

Sep
30
1 month ago
Activity icon

Started a new Conversation Moving Public Folder To Server Web Root Directory, Laravel 5.6

I just set up a Raspberry Pi 4 to run a Laravel project I've been working on. I've pulled the project in with git in the directory /var/www/pi_theater_2 (I'm using Apache). I originally had it in /var/www/html/pi_theater_2, but I gather that's not a good idea because things like your .env file will be made public.

So from what I understand I need to move my public folder and it's contents to the Apache web root directory. I'd like to keep it under the "pi_theater_2" directory, just to keep everything separate in case I ever make another project in /var/www/html. So ideally I'd move /var/www/pi_theater_2/public and it's contents to /var/www/html/pi_theater_2/public. Does that sound correct? Would I then be able to pull up the home page of my site by simply visiting "https://my-pi4-ip-address/pi_theater_2"?

I keep seeing online that I should edit my index.php and bootstrap/app.php files to change path.public to /var/www/html/pi_theater_2/public, but I don't even see that variable defined in either of those files. Should I do something different for version 5.6 of Laravel?

EDIT: About that last paragraph, I was mistaken. I thought I was supposed to edit the path variables, but I was supposed to ADD them. I was following instructions from this page https://www.pixelvars.com/laravel-change-public-html-to-public_html-the-right-way/

EDIT2: I've gone ahead and moved everything to /var/www/html/pi_theater_2 (no public folder in that directory, that IS the public directory itself). I've added the paths to bootstrap/app,php and index.php like was suggested on the page I linked to. For reference, I also followed instructions from this page: https://laravel-news.com/subfolder-install

My page seems to be working correctly except for one thing. When I do an npm run dev to compile any changes to my JS, it seems to be compiling everything to the old public directory, /var/www/pi_theater_2/public. I think I read somewhere that Elixir also has a public path variable defined somewhere that I'll need to change?

Sep
27
1 month ago
Activity icon

Replied to ERR_CONNECTION_REFUSED From Laravel Project On Apache Server

It should be, yes. I haven't altered the default public folder stuff.

Sep
26
1 month ago
Activity icon

Started a new Conversation ERR_CONNECTION_REFUSED From Laravel Project On Apache Server

I've just setup a Raspberry Pi 4 with Apache 2, PHP 7.2 (or 7.3, not sure as there were some complications when installing things), MariaDB, and Laravel 5.6.

I had a project I was working on which I cloned with git into the directory /var/www/html/pi_theater_2.

I installed Composer and did a composer install and npm install. My .env file is setup and seems to have everything set. I believe I ran a a2enmod rewrite to enable mod_rewrite and restarted Apache...

I've setup the necessary user with MySQL, added the database for the project, inserted a bunch of test data, etc.

I've setup everything I can think to setup. But when I connect to the same network as the Pi and visit it's static IP in Chrome, https://192.168.1.204/pi_theater_2, I get the ERR_CONNECTION_REFUSED. There doesn't seem to be anything in the access or error logs for Apache. I've got a file at /var/www/html/index.php that just does a phpinfo(), it works.

Anyone know what I'm missing or how I can troubleshoot this further?

Jul
12
4 months ago
Activity icon

Replied to Where With Difference Of 2 Columns

I figured it out with whereRaw:

$quota_date =
    DB::table('deadline_calendar_quota')
        ->select('quota_date')
        ->where('active', '=', 'y')
        ->where('quota_date', '>=', $quota_start_date)
        ->when($embroidery > 0, function($query) use ($embroidery) {
                    return
                        $query
                            ->whereRaw(
                                'CAST(emb_quota AS SIGNED) - CAST(emb_units_sold AS SIGNED) >= ?',
                                [$embroidery]
                            );
                })
        ->when($screen > 0, function($query) use ($screen) {
                    return
                        $query
                            ->whereRaw(
                                'CAST(print_quota AS SIGNED) - CAST(print_units_sold AS SIGNED) >= ?',
                                [$screen]
                            );
                })
        ->orderBy('quota_date', 'ASC')
        ->limit(1)
        ->get();
Activity icon

Replied to Where With Difference Of 2 Columns

I've added the create code to the original comment. Basically the table is for tracking production day by day, so that we don't sell more units than we can actually produce and get shipped out on time. So there's a date (the quota_date), and embroidery quota, a screen print quota, and then the actual number of embroidery and screen print units sold for that quota date.

I had the orderBy on there because I need to get the earliest available quota date. I guess I wasn't sure how it would be sorted without it, so I didn't want to get, for instance, the latest open quota date.

Activity icon

Replied to Where With Difference Of 2 Columns

I'm using Validator to check the post data before processing anything, this is what I have for that particular part of the JSON:

    'product_types.embroidery.qty' => 'required|integer|min:0'

Is there anything else I should be doing to avoid SQL injection?

Activity icon

Started a new Conversation Where With Difference Of 2 Columns

I'm working with Laravel v5.4.36

Like the title says, I'm trying to do something like this:

SELECT *
FROM table
WHERE column1 - column2 > 50

Where 50 would be some variable value in a request object. This is doable in plain SQL, but I can't figure out how to do it with Laravel's query builder. The clause also needs to be conditional, so it needs to be inside of a when(), if that makes a difference. Here's what I have now:

$embroidery = $request->input('product_types.embroidery.qty');
$screen = $request->input('product_types.screen.qty');

// Hardcoded for now
$buffer_days = 17;  

$quota_date =
    DB::table('deadline_calendar_quota')
        ->select('quota_date')
        ->where('active', '=', 'y')
        ->where('quota_date', '>=', "NOW() + INTERVAL $buffer_days DAY")
        ->when($embroidery > 0, function($query) use ($embroidery) {
            return $query->where(DB::raw('emb_quota - emb_units_sold'), '>=', $embroidery);
        })
        ->when($screen > 0, function($query) use ($screen) {
            return $query->where(DB::raw('print_quota - print_units_sold'), '>=', $screen);
        })
        ->orderBy('quota_date', 'ASC')
        ->limit(1)
        ->get();

EDIT: This gives the following error: "Object of class Illuminate\Support\Collection could not be converted to int"

EDIT 2: Here's the table create code in case anyone is curious

CREATE TABLE `deadline_calendar_quota` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `quota_date` DATE NULL DEFAULT NULL,
    `emb_units_sold` INT(10) UNSIGNED NULL DEFAULT NULL,
    `print_units_sold` INT(10) UNSIGNED NULL DEFAULT NULL,
    `emb_quota` INT(10) UNSIGNED NULL DEFAULT NULL,
    `print_quota` INT(10) UNSIGNED NULL DEFAULT NULL,
    `emb_rush_quota` INT(10) UNSIGNED NULL DEFAULT NULL,
    `print_rush_quota` INT(10) UNSIGNED NULL DEFAULT NULL,
    `active` ENUM('y','n') NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `date_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `added_by_id` INT(10) UNSIGNED NULL DEFAULT NULL,
    `date_last_modified` DATETIME NOT NULL,
    `last_modified_by_id` INT(10) UNSIGNED NULL DEFAULT NULL,
    `date_last_locked` DATETIME NULL DEFAULT NULL,
    `last_locked_by_id` INT(10) UNSIGNED NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE INDEX `quota_date_index` (`quota_date`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=4696838
;

May
21
5 months ago
Activity icon

Started a new Conversation Eloquent ORM Nested Eager Loaded Relations

Okay, I have a Laravel app I'm working on that's like a Netflix style streaming service. My main table for movies / TV shows looks like this:

CREATE TABLE `media` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `media_type` ENUM('movie','show') NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `title` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `summary` VARCHAR(4000) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `notes` VARCHAR(191) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
    `poster` VARCHAR(191) NOT NULL DEFAULT 'missing-poster.jpg' COLLATE 'utf8mb4_unicode_ci',
    `jumbotron` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=176
;

I designed everything with the idea that there could be multiple hard drives with content on them in the future (right now there's only one). So I have a drives table:

CREATE TABLE `drives` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE INDEX `drives_name_unique` (`name`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2
;

I also have an episodes table that looks like this:

CREATE TABLE `episodes` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `media_id` INT(10) UNSIGNED NOT NULL,
    `season` INT(10) UNSIGNED NOT NULL,
    `episode_number` INT(10) UNSIGNED NOT NULL,
    `title` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `summary` VARCHAR(4000) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE INDEX `episodes_media_id_season_episode_number_unique` (`media_id`, `season`, `episode_number`),
    CONSTRAINT `episodes_media_id_foreign` FOREIGN KEY (`media_id`) REFERENCES `media` (`id`) ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=616
;

And finally I have the pivot tables, episode_file and file_movie that join a drive with an episode or movie:

CREATE TABLE `episode_file` (
    `episode_id` INT(10) UNSIGNED NOT NULL,
    `drive_id` INT(10) UNSIGNED NOT NULL,
    `filename` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE INDEX `episode_file_drive_id_episode_id_unique` (`drive_id`, `episode_id`),
    INDEX `episode_file_episode_id_foreign` (`episode_id`),
    CONSTRAINT `episode_file_drive_id_foreign` FOREIGN KEY (`drive_id`) REFERENCES `drives` (`id`) ON DELETE CASCADE,
    CONSTRAINT `episode_file_episode_id_foreign` FOREIGN KEY (`episode_id`) REFERENCES `episodes` (`id`) ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

CREATE TABLE `file_movie` (
    `media_id` INT(10) UNSIGNED NOT NULL,
    `drive_id` INT(10) UNSIGNED NOT NULL,
    `filename` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE INDEX `file_movie_drive_id_media_id_unique` (`drive_id`, `media_id`),
    INDEX `file_movie_media_id_foreign` (`media_id`),
    CONSTRAINT `file_movie_drive_id_foreign` FOREIGN KEY (`drive_id`) REFERENCES `drives` (`id`) ON DELETE CASCADE,
    CONSTRAINT `file_movie_media_id_foreign` FOREIGN KEY (`media_id`) REFERENCES `media` (`id`) ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

What I want is to be able to return from a media controller one record that looks like this as a Javascript object:

{
    id: 1,
    title: 'Alien',
    summary: 'fdsafdsafdsa',
    notes: null,
    poster: 'alien.jpg',
    jumbotron: null,
    created_at: '2019-05-21 00:00:00',
    updated_at: '2019-05-21 00:00:00',
    file: {
        drive_id: 1,
        media_id: 1,
        created_at: '2019-05-21 00:00:00',
        updated_at: '2019-05-21 00:00:00',
        drive: {
            id: 1,
            name: 'hdd1',
            created_at: '2019-05-21 00:00:00',
            updated_at: '2019-05-21 00:00:00',
        }
    }
}

I have it now where I can join the episode_file or file_movie record onto the media record, but I don't have the 'name' field of the drive from the drives table (hdd1 in this example). That's what I want, to be able to get that without a second query or API call. Anyone know how I can do this with Eloquent relationships?

EDIT: Some more detail, here's my Media model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Laravel\Scout\Searchable;

class Media extends Model
{
    use Searchable;

    public function genres() {
        return $this->belongsToMany('App\Genre');
    }

    public function collections() {
        return $this->belongsToMany('App\Collection');
    }

    public function filename() {
        return $this->hasOne('App\FileMovie');
    }

    public function episodes() {
        return $this->hasMany('App\Episode', 'media_id', 'id');
    }

    public function toSearchableArray() {
        $array = $this->toArray();

        $array['created_at_unix'] = $this->created_at->timestamp;
        $array['updated_at_unix'] = $this->updated_at->timestamp;

        return $array;
    }
}

My Drive model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Drive extends Model
{
    //
}

The EpisodeFile and FileMovie models:

<?php

namespace App;

use Illuminate\Database\Eloquent\Relations\Pivot;

class EpisodeFile extends Pivot
{
    public $table = 'episode_file';
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Relations\Pivot;

class FileMovie extends Pivot
{
    public $table = 'file_movie';
}

Here's my MediaController:

<?php

namespace App\Http\Controllers;

use App\Media;
use Illuminate\Http\Request;

class MediaController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Media  $media
     * @return \Illuminate\Http\Response
     */
    public function show(Media $media, $id)
    {
        return
            Media::find($id)
                ->load('genres')
                ->load('episodes')
                ->load('filename');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Media  $media
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Media $media)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Media  $media
     * @return \Illuminate\Http\Response
     */
    public function destroy(Media $media)
    {
        //
    }
}

And here's what the JSON looks like when I call that controller:

{
    "id": 94,
    "media_type": "movie",
    "title": "Spider-Man: Homecoming",
    "summary": "Peter Parker balances his life as an ordinary high school student in Queens with his superhero alter-ego Spider-Man, and finds himself on the trail of a new menace prowling the skies of New York City.",
    "notes": null,
    "poster": "spiderman-homecoming.jpg",
    "jumbotron": "",
    "created_at": "2017-10-18 20:57:32",
    "updated_at": "2017-10-18 20:57:32",
    "genres": [
        {
            "id": 1,
            "name": "Action",
            "created_at": "2018-03-04 08:42:36",
            "updated_at": "2018-03-04 08:42:36",
            "pivot": {
                "media_id": 94,
                "genre_id": 1
            }
        },
        {
            "id": 5,
            "name": "Comedy",
            "created_at": "2018-03-04 08:42:37",
            "updated_at": "2018-03-04 08:42:37",
            "pivot": {
                "media_id": 94,
                "genre_id": 5
            }
        },
        {
            "id": 22,
            "name": "Superhero",
            "created_at": "2018-03-04 08:42:37",
            "updated_at": "2018-03-04 08:42:37",
            "pivot": {
                "media_id": 94,
                "genre_id": 22
            }
        }
    ],
    "episodes": [],
    "filename": {
        "media_id": 94,
        "drive_id": 1,
        "filename": "spiderman-homecoming.mp4",
        "created_at": "2019-05-21 11:16:08",
        "updated_at": "2019-05-21 11:16:08"
    }
}

Again, basically I just want to also get the drive name somehow in that filename property.