<commit_before><?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function(){
    //
    Route::get('/search/{filter}', function($filter){
        $data = '';
        $filter_arr = explode(':', $filter);
        
        switch($filter_arr[0]){
            case 'province':
                $province = DB::table('provinces')->where('id', $filter_arr[1])->first();
                $data['cities'] = DB::table('cities')->where('description', 'like', '%' . strtolower($province->name) . '%')->get();
                break;
            
            case 'branches':
                $data['branches'] = DB::table('users')
                    ->select('branch')
                    ->where('branch', '!=', 'null')
                    ->where('branch', '!=', '')
                    ->groupBy('branch')
                    ->orderBy('branch', 'asc')
                    ->get();
                
                break;
        }
        
        echo json_encode($data);
    });
    
    Route::get('/update', function(){
        switch($_GET['type']){
            case 'tag':
                $data = App\Item::find($_GET['id']);
                $data->is_sold = 1;
                $data->save();
                break;
        }
        
        echo json_encode($data);
    });
    
    Route::get('/', function(){
        $data['items'] = DB::table('items')->orderBy('ticket_no', 'desc')->paginate(6);
        //$data['provinces'] = DB::table('provinces')->lists('name', 'id');
        $provinces = DB::table('provinces')->orderBy('name', 'asc')->get();
        $data['pawnshops'] = DB::table('pawnshops')->lists('name', 'id');
        
        foreach($provinces as $value){
            $res = DB::table('cities')->where('description', 'like', '%' . strtolower($value->name) . '%')->get();
            
            if($res){
                foreach($res as $val) $data['provinces'][strtolower($value->name)][] = $val->name;
            }
            else $data['provinces'][strtolower($value->name)][] = '';
        }
        //print_r($data['provinces']); die();
        return view('welcome', ['data'=>$data]);
    });

    Route::resource('contact', 'ContactController');
    Route::resource('pricing', 'PricingController');
    Route::resource('about', 'AboutController');<commit_msg>gor github issue #19<commit_after><?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function(){
    //
    Route::get('/search/{filter}', function($filter){
        $data = '';
        $filter_arr = explode(':', $filter);
        
        switch($filter_arr[0]){
            case 'province':
                $province = DB::table('provinces')->where('id', $filter_arr[1])->first();
                $data['cities'] = DB::table('cities')->where('description', 'like', '%' . strtolower($province->name) . '%')->get();
                break;
            
            case 'branches':
                $data['branches'] = DB::table('users')
                    ->select('branch')
                    ->where('branch', '!=', 'null')
                    ->where('branch', '!=', '')
                    ->groupBy('branch')
                    ->orderBy('branch', 'asc')
                    ->get();
                
                break;
        }
        
        echo json_encode($data);
    });
    
    Route::get('/update', function(){
        switch($_GET['type']){
            case 'tag':
                $data = App\Item::find($_GET['id']);
                $data->is_sold = 1;
                $data->save();
                break;
        }
        
        echo json_encode($data);
    });
    
    Route::get('/', function(){
        $data['items'] = DB::table('items')->where(['is_sold'=>0])->orderBy('ticket_no', 'desc')->paginate(6);
        //$data['provinces'] = DB::table('provinces')->lists('name', 'id');
        $provinces = DB::table('provinces')->orderBy('name', 'asc')->get();
        $data['pawnshops'] = DB::table('pawnshops')->lists('name', 'id');
        
        foreach($provinces as $value){
            $res = DB::table('cities')->where('description', 'like', '%' . strtolower($value->name) . '%')->get();
            
            if($res){
                foreach($res as $val) $data['provinces'][strtolower($value->name)][] = $val->name;
            }
            else $data['provinces'][strtolower($value->name)][] = '';
        }
        //print_r($data['provinces']); die();
        return view('welcome', ['data'=>$data]);
    });

    Route::resource('contact', 'ContactController');
    Route::resource('pricing', 'PricingController');
    Route::resource('about', 'AboutController');
{'fraction_non_alphanumeric': 0.2767244197450147, 'fraction_numerical': 0.0017979731938542007, 'mean_word_length': 1.5742532604122843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '2533678', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1569, 'n_words': 328}