<commit_before><?php

namespace App\Http\Controllers;

use App\Http\web\vk\exceptions\VkApiException;
use App\Http\web\vk\methods\Account;
use App\Http\web\vk\methods\Users;
use Illuminate\Http\Request;
use App\Http\web\vk\Vk;
use Carbon\Carbon;
use App\UserToken;
use App\User;

class UserTokenController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        // TODO Temporary
        return response()->json(UserToken::with('user')->get());
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     *
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $userToken = UserToken::with('user')->findOrFail($id);

        return response()->json($userToken);
    }

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

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     *
     * @return \Illuminate\Http\Response
     */<commit_msg>Working update method in UserTokenController<commit_after><?php

namespace App\Http\Controllers;

use App\Http\web\vk\exceptions\VkApiException;
use App\Http\web\vk\methods\Account;
use App\Http\web\vk\methods\Users;
use Illuminate\Http\Request;
use App\Http\web\vk\Vk;
use Carbon\Carbon;
use App\UserToken;
use App\User;

class UserTokenController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        // TODO Temporary
        return response()->json(UserToken::with('user')->get());
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     *
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $userToken = UserToken::with('user')->findOrFail($id);

        return response()->json($userToken);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     *
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name'        => 'nullable|string|max:' . self::MAX_LEN_STRING_DB,
            'description' => 'nullable|string|max:600',
        ]);

        $userToken = UserToken::findOrFail($id);
        $userToken->name = $request->exists('name') ? $request->name : $userToken->name;
        $userToken->description = $request->exists('description') ? $request->description : $userToken->description;
        $userToken->save();

        return response()->json($userToken);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     *
     * @return \Illuminate\Http\Response
     */
{'fraction_non_alphanumeric': 0.14003189792663476, 'fraction_numerical': 0.0009569377990430622, 'mean_word_length': 2.3361702127659574, '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': '4934532', 'n_tokens_mistral': 955, 'n_tokens_neox': 966, 'n_words': 193}