<commit_before><?php

namespace App\Http\Controllers;

use App\Client;
use App\Client_user;
use App\Events\UserApproved;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        if(!Auth::user()->isAdmin() && !Auth::user()->isAdmin()) {
            abort(402, "Nope.");
        }

        if (Auth::user()->isSuperAdmin() && Route::current()->getPrefix() == '/superadmin')
        {
            $users = User::orderBy('name')->get();
        }
        else
        {
            $users = Client::findorfail(Auth::user()->currentclient_id)->user_all()->get();
        }
        return view('user.index')->with('users', $users);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        abort(402, "Nope.");
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        abort(402, "Nope.");
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $user =  Auth::user();
        return view('user.profile')->with('user', $user);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //Refuse wenn 1. kein Admin oder Superadmin<commit_msg>Update UserController.php<commit_after><?php

namespace App\Http\Controllers;

use App\Client;
use App\Client_user;
use App\Events\UserApproved;
use App\Position;
use App\Qualification_user;
use App\Service;
use App\Training;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        if(!Auth::user()->isAdmin() && !Auth::user()->isAdmin()) {
            abort(402, "Nope.");
        }

        if (Auth::user()->isSuperAdmin() && Route::current()->getPrefix() == '/superadmin')
        {
            $users = User::orderBy('name')->get();
        }
        else
        {
            $users = Client::findorfail(Auth::user()->currentclient_id)->user_all()->get();
        }

        return view('user.index')->with('users', $users);

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        abort(402, "Nope.");
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        abort(402, "Nope.");
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $user =  Auth::user();

        $saison = Auth::user()->currentclient()->Season();

        $wrd1 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '1' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');
        $boot1 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '2' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');
        $sr1 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '3' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');
        $rd1 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '4' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');
        $f1 =Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '5' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');
        $rsr1 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id', '=', '6'  )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit');

        $wrd2 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '1' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');
        $boot2 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '2' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');
        $sr2 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '3' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');
        $rd2 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '4' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');
        $f2 =Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '5' )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');
        $rsr2 = Position::where('user_id', '=', Auth::user()->id)
            ->join('services', 'positions.service_id', '=', 'services.id')
            ->where('services.date', '<', DB::raw('CURDATE()'))
            ->where('positions.credittype_id_zwei', '=', '6'  )
            ->whereBetween('services.date', [$saison["from"], $saison["to"]])
            ->where('services.client_id', '=', Auth::user()->currentclient_id)->sum('credit_zwei');

        $wrd = $wrd1 + $wrd2;
        $boot = $boot1 + $boot2;
        $sr = $sr1 + $sr2;
        $rd = $rd1 + $rd2;
        $f = $f1 + $f2;
        $rsr = $rsr1 + $rsr2;

        return view('user.profile', compact('wrd', 'boot', 'sr', 'rd', 'f', 'rsr'))->with('user', $user);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //Refuse wenn 1. kein Admin oder Superadmin
{'fraction_non_alphanumeric': 0.21682401612389943, 'fraction_numerical': 0.005940384003394505, 'mean_word_length': 2.6770670826833074, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 121, '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': '2124450', 'n_tokens_mistral': 2993, 'n_tokens_neox': 2939, 'n_words': 462}