<commit_before><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Support\Facades\Auth;
use App\Models\Document;
use App\Models\Application;
use App\Models\User;

class DocumentController extends Controller
{
    public function deleteDocument(Request $request, Document $document)
    {
        // Does this document belong to the current user?
        if($document->user->id != Auth::user()->id)
        {
            $request->session()->flash('error', 'Only the person who uploaded a file may delete it.');
            return redirect('/login');
        }

        $application = $document->application->id;

        $document->delete();
        $request->session()->flash('success', 'Your file has been deleted.');
        return redirect()->back();
    }

    public function addDocument(Application $application, Request $request)
    {<commit_msg>Delete files completely<commit_after><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Support\Facades\Auth;
use App\Models\Document;
use App\Models\Application;
use App\Models\User;
use Illuminate\Support\Facades\File;

class DocumentController extends Controller
{
    public function deleteDocument(Request $request, Document $document)
    {
        // Does this document belong to the current user?
        if($document->user->id != Auth::user()->id)
        {
            $request->session()->flash('error', 'Only the person who uploaded a file may delete it.');
            return redirect('/login');
        }

        $path = public_path() . '/files/user/' . $document->file;

        $document->delete();
        File::delete($path);
        $request->session()->flash('success', 'Your file has been deleted.');
        return redirect()->back();
    }

    public function addDocument(Application $application, Request $request)
    {
{'fraction_non_alphanumeric': 0.13309894525364138, 'fraction_numerical': 0.0, 'mean_word_length': 3.1936842105263157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2885515', 'n_tokens_mistral': 519, 'n_tokens_neox': 532, 'n_words': 141}