<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Max
 * Date: 11/17/2014
 * Time: 6:05 PM
 */

class RideController extends BaseController {

    protected function getRides() {
        if (Input::has('searchTo') || Input::has('searchFrom')){
            $rides = Ride::where(function($query)
            {
                // Try to add to
                if (Input::has('searchTo')) {
                    $query->where('destination', 'LIKE', '%' . Input::get('searchTo') . '%');
                }
                // Try to add from
                if (Input::has('searchFrom')) {
                    $query->where('origin', 'LIKE', '%' . Input::get('searchFrom') . '%');
                }

                // If advanced is checked
                if (Input::has('advanced')) {
                    // Try to add price
                    if (Input::has('price')) {
                        $query->where('price', 'LIKE', '%' . Input::get('price') . '%');
                    }
                    // Try to add date
                    if (Input::has('date')) {
                        $query->where('date', 'LIKE', '%' . Input::get('date') . '%');
                    }
                    // Try to add available seats
                    if (Input::has('seats')) {
                        $query->where('seats', 'LIKE', '%' . Input::get('seats') . '%');
                    }
                }
            })->orderBy('date', 'asc')->get();
        } else {
            if (Input::has('search')){
                $rides =Ride::where(function($query){
                                        $query->where('destination', 'LIKE', '%' . Input::get('search') . '%')
                                              ->orwhere('origin', 'LIKE', '%' . Input::get('search') . '%');
                                    })->orderBy('date', 'asc')->get();
            }
            else {
                $rides = Ride::orderBy('date', 'asc')->get();
            }
        }
        return $rides;
    }

    public function index() {
        return View::make('rides.index')->with('rides', $this->getRides());
    }

    public function create() {

    }

    public function store() {
        // validate
        // read more on validation at http://laravel.com/docs/validation
        $rules = array(
            'destination' => 'required',
            'origin'      => 'required',<commit_msg>edit sql statements to not display older rides<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Max
 * Date: 11/17/2014
 * Time: 6:05 PM
 */

class RideController extends BaseController {

    protected function getRides() {
        if (Input::has('searchTo') || Input::has('searchFrom')){
            $rides = Ride::where(function($query)
            {
                // Try to add to
                if (Input::has('searchTo')) {
                    $query->where('destination', 'LIKE', '%' . Input::get('searchTo') . '%');
                }
                // Try to add from
                if (Input::has('searchFrom')) {
                    $query->where('origin', 'LIKE', '%' . Input::get('searchFrom') . '%');
                }

                // If advanced is checked
                if (Input::has('advanced')) {
                    // Try to add price
                    if (Input::has('price')) {
                        $query->where('price', 'LIKE', '%' . Input::get('price') . '%');
                    }
                    // Try to add date
                    if (Input::has('date')) {
                        $query->where('date', 'LIKE', '%' . Input::get('date') . '%');
                    }
                    // Try to add available seats
                    if (Input::has('seats')) {
                        $query->where('seats', 'LIKE', '%' . Input::get('seats') . '%');
                    }
                }
                
                $query->where('date', '>', new DateTime('today'));
            })->orderBy('date', 'asc')->get();
        } else {
            if (Input::has('search')){
                $rides = Ride::where(function($query){
                                        $query->where('destination', 'LIKE', '%' . Input::get('search') . '%')
                                              ->orwhere('origin', 'LIKE', '%' . Input::get('search') . '%');
                                        $query->where('date', '>', new DateTime('today'));
                                    })->orderBy('date', 'asc')->get();
            }
            else {
                $rides = Ride::where('date', '>', new DateTime('today'))->orderBy('date', 'asc')->get();
            }
        }
        return $rides;
    }

    public function index() {
        return View::make('rides.index')->with('rides', $this->getRides());
    }

    public function create() {

    }

    public function store() {
        // validate
        // read more on validation at http://laravel.com/docs/validation
        $rules = array(
            'destination' => 'required',
            'origin'      => 'required',
{'fraction_non_alphanumeric': 0.18266560888536296, 'fraction_numerical': 0.00436334787782626, 'mean_word_length': 1.281900452488688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1765727', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1268, 'n_words': 256}