• laravel

    Laravel – the requested url was not found on this server

    This error is mostly cause .htaccess file is not set up.

    write the below coding in .htaccess file in laravel

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
    
        RewriteEngine On
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>

  • laravel,  php,  phpmyadmin

    Laravel join sql query syntax with where between group by

    Its a query to join two tables and get the details in between given date format ,according to month (month wise) and of specific city .

    sample work

    Simple SQL query

    the query in simple SQL to be added in any language .

    select count(*) as count , city , MONTH(`abctable`.`created_at`) as mm, YEAR(`abctable`.`created_at`)as yy from `abctable` join `xyztable` on `abctable`.`entity_id` = `xyztable`.`parent_id` where `abctable`.`created_at` between '2019-04-24 00:00:00' and '2019-09-12 12:12:12' AND `xyztable`.`city`='Pune' GROUP BY YEAR(`abctable`.`created_at`),MONTH(`abctable`.`created_at`)

    Laravel SQL query

    the sql query in laravel controller form data.

     $users = DB::table('abctable')
            ->select(DB::raw('count(*) as count, MONTH(abctable.created_at) as MM, YEAR(abctable.created_at) as YY'))
            ->join('xyztable', 'n3d_sales_flat_order_grid.entity_id', '=', 'xyztable.parent_id')
            ->whereBetween('abctable.created_at',[new Carbon($fdate),new Carbon($gdate)])
            ->where('xyztable.city','like',$city)
            ->groupBy(DB::raw('MONTH(abctable.created_at)'),DB::raw('YEAR(abctable.created_at)'))
            ->get();
  • javascript,  laravel,  mysql,  php

    Laravel-date format variable SQL query for API value

    given date value in string format , getting error in SQL query , so have to change it into date format in Laravel using Carbon function ( for date time )

    laravel controller sample work to get values in json [RestAPI]
    <?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use App\Http\Resources\OrdersCollection;
    use Illuminate\Support\Facades\DB;
    use App\Http\Controllers\Controller;
    use app\Orders;
    use Response;
    use Carbon\Carbon;
    
    class OrdersController extends Controller
    {
        //
        public function index(Request $request)
        {
            $fdate = $request->query('fdate');
            $gdate = $request->query('gdate');
    
    
            $users = DB::table('abctable')
                ->select(DB::raw('count(*) as count, city'))
                ->join('n3d_sales_flat_order_address', 
             'abctable.entity_id', '=', 'xyztable.parent_id')
                ->whereBetween('abctable.created_at',[new Carbon($fdate),new Carbon($gdate)])
                ->groupBy('xyztable.city')
                ->get();
               
           return Response::json($users);
        }
    }
    

    Carbon function

    $users = DB::table(‘abctable’)
    ->select(DB::raw(‘count(*) as count, city’))
    ->join(‘n3d_sales_flat_order_address’,
    ‘abctable.entity_id’, ‘=’, ‘xyztable.parent_id’)
    ->whereBetween(‘abctable.created_at’,[new Carbon($fdate),new Carbon($gdate)])
    ->groupBy(‘xyztable.city’)
    ->get();

  • laravel

    how to add image , url in laravel view

    add image to view

    <img src=” {{ asset(‘img/myimage.png’) }} ” >

    Explaination : here asset is pointed to public folder in laravel , where lies the img folder containing images.

    Reference : https://stackoverflow.com/a/36441835/12423259

    Add url of next page in view

    <a href=” {{url(‘/main/dashboard’)}} “> click </a>

    Explaination : here main is controller class name and dashboard is a method where code for view is placed in laravel.

  • laravel,  php

    Laravel install in windows

    By Laravel Installer method

    • Install composer https://getcomposer.org/download/
    • In command Line write composer global require “laravel/installer”
    • Now go to path c:/wamp/www in cmd
    • now write further C:/wamp/www laravel new projectname

    By composer Installer method

    • Install composer https://getcomposer.org/download/
    • Now go to path c:/wamp/www in cmd
    • now write further composer create-project –prefer-dist laravel/laravel projectname

    thus the laravel file is installed for development.