<?php

namespace App\Http\Controllers\Website;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Fish;
use App\Models\Fish_type;
use App\Models\Page;
use App\Models\Section;

class SpeciesController extends Controller
{
    public function species($species_id)
    {
        $page = Page::Active()->MainPages()->where('link', 'species')->first();
		$sections = Section::Active()->where('page_id', $page->id)->orderBy('order')->get();
        $species = Fish_type::Active()->findOrFail($species_id);
        $fishes = Fish::Active()->where('fish_type_id', $species->id)->get();

        return view('website.pages.species')->with([
            'page' => $page,
			'sections' => $sections,
            'fishes' => $fishes
        ]);
    }

    public function fish($fish_id)
    {
        $fish = Fish::Active()->findOrFail($fish_id);
        $related_fishes = Fish::Active()->where('fish_type_id', $fish->fish_type_id)->get();


        return view('website.pages.subpages.fish')->with([
            'fish' => $fish,
            'related_fishes' => $related_fishes
        ]);
    }
}
