<?php

namespace App\Modules\Admin;

use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\BaseController;

class TaskTemplatesController extends BaseController
{
    /**
     *	The layout that should be used for responses.
     */
    protected $layout = 'layouts.master';

    public function index()
    {
        // Check if user has permission to manage task templates
        // Using a more appropriate permission or fallback to admin group check
        if (! Auth::user()->hasPermission('manage_task_templates') && ! Auth::user()->isMemberOf([4, 5])) {
            $this->layout->content = View::make('admin::no-permission', [
                'feature' => 'Task Templates',
                'description' => 'You need the "Manage Task Templates" permission or be a member of the admin/management group to access this feature.',
                'required_permission' => 'manage_task_templates'
            ]);
            return;
        }

        $this->layout->content = View::make('admin::settings.task-templates');
    }
}
