• nimmy

    how to get year from dateofbirth.this dob taken from database.i used below code
    $user_gender=’male';
    $user_religion=’hindu';
    $user_caste=’nair';
    $user_state=’karnataka';
    $minage=18;
    $maxage=25;
    //$posts = Post::whereYear($dob)->get();
    $today = date(“Y”);
    //$today=Carbon::now();
    echo $today;
    $maxdate=$today-$maxage;
    echo $maxdate;
    $mindate=$today-$minage;
    if($user_gender==’male’)
    {
    $search_gender=”female”;
    }
    else
    {
    $search_gender=”male”;
    }
    $query = DB::table(‘user_profile’)
    ->join(‘user_reg’, ‘user_reg.id’, ‘=’, ‘user_profile.user_id’)
    ->where(‘user_reg.gender’,’=’,$search_gender)
    ->whereBetween(‘YEAR(user_reg.dob)’,[$mindate,$maxdate]);
    but not working.plz give ans in laravel 5

  • sarath

    $data = DB::table(‘table_name’)
    ->select(DB::raw(YEAR(dateofbirth)))
    ->get();

  • Tiago Matias Rogério

    It’s giving an error like: PHP Fatal error: Cannot redeclare class CreateUsersTable in xxxx while running php artisan migrate

  • Bachhu singh

    Class AppHttpControllersAccountController does not exist plz help..