<commit_before><?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Entities\Trip;
use App\Entities\User;
use Carbon\Carbon;

class TripController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function index()
    {
  
        $Trips = Trip::all();
  
        return response()->json($Trips);
  
    }
  
    public function create(Request $request)
    {
        try {
            $inputs = $request->all();
            $user = User::where('email', $inputs['email'])->first();

            $inputsCreate['vehicle_id'] = $inputs['vehicle_id'];
            $inputsCreate['fuel_cost'] = $inputs['fuel_cost'];
            $inputsCreate['fuel_amount'] = $inputs['fuel_amount'];
            $inputsCreate['end_mileage'] = $inputs['end_mileage'];
            $inputsCreate['fuel_type'] = $inputs['fuel_type'];
            $inputsCreate['tank_fill_up'] = $inputs['tank_fill_up'];
            $inputsCreate['company_id'] = $user->company_id;
            $trip = Trip::where('company_id', $inputsCreate['company_id'])->first();
            $inputsCreate['trip_type_id'] = $trip->trip_type_id;
            $inputsCreate['pickup_date'] = Carbon::now();
            $Trip = Trip::forceCreate($inputsCreate);
    
            if (is_numeric($Trip->id)) {
                $success = true;
            } else {
                $success = false;
            }
        } catch (\Exception $e) {
            $success = false;
        }
        
        return response()->json(["success" => $success]);
    }
}<commit_msg>#2 Correções para cadastro de trip pelo app<commit_after><?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Entities\Trip;
use App\Entities\User;
use Carbon\Carbon;
use Log;
use App\Entities\Type;

class TripController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function index()
    {
  
        $Trips = Trip::all();
  
        return response()->json($Trips);
  
    }
  
    public function create(Request $request)
    {
        try {
            $inputs = $request->all();
            $user = User::where('email', $inputs['email'])->first();
            $inputsCreate['vehicle_id'] = $inputs['vehicle_id'];
            $inputsCreate['fuel_cost'] = $inputs['fuel_cost'];
            $inputsCreate['fuel_amount'] = $inputs['fuel_amount'];
            $inputsCreate['end_mileage'] = $inputs['end_mileage'];
            $inputsCreate['fuel_type'] = $inputs['fuel_type'];
            $inputsCreate['tank_fill_up'] = $inputs['tank_fill_up'];
            $inputsCreate['company_id'] = $user->company_id;
            $type = Type::where('company_id', $inputsCreate['company_id'])
                        ->where('entity_key', 'trip')
                        ->first();
            $inputsCreate['trip_type_id'] = $type->id;
            $inputsCreate['pickup_date'] = Carbon::now();
            $Trip = Trip::forceCreate($inputsCreate);

            if (is_numeric($Trip->id)) {
                $success = true;
            } else {
                $success = false;
            }
        } catch (\Exception $e) {
            Log::info($e->getMessage());
            $success = false;
        }
        
        return response()->json(["success" => $success]);
    }
}
{'fraction_non_alphanumeric': 0.15536166619757952, 'fraction_numerical': 0.00028145229383619476, 'mean_word_length': 2.1312775330396474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1443928', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1030, 'n_words': 179}