use App\Entities\Projects\Project;
use App\Services\InvoiceDrafts\InvoiceDraftCollection;
use Illuminate\Http\Request;
class DraftsController extends Controller
{
private $draftCollection;
public function __construct()
{
$this->draftCollection = new InvoiceDraftCollection();
}
public function index(Request $request)
{
$draft = $this->draftCollection->content()->first();
$projects = Project::pluck('name', 'id');
return view('invoice-drafts.index', compact('draft', 'projects'));
}
public function show(Request $request, $draftKey = null)
{
$draft = $draftKey ? $this->draftCollection->get($draftKey) : $this->draftCollection->content()->first();
if (is_null($draft)) {
flash(__('invoice.draft_not_found'), 'danger');
return redirect()->route('invoice-drafts.index');
}
$projects = Project::pluck('name', 'id');
return view('invoice-drafts.index', compact('draft', 'projects'));
}
//
}