ssquare

ssquare

Member Since 3 Months Ago

Experience Points 880
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

01 Nov
1 month ago

ssquare left a reply on Cannot Insert Duplicate Key Row In Object 'dbo.student' With Unique Index 'dept_id_room_id_roll_id_unique'. The Duplicate Key Value Is (<NULL>, <NULL>, <NULL>)

Isn't there any other way? I think it might lead to another confusion during update. Such as update where roll_ id = $roll_id .

ssquare started a new conversation Cannot Insert Duplicate Key Row In Object 'dbo.student' With Unique Index 'dept_id_room_id_roll_id_unique'. The Duplicate Key Value Is (<NULL>, <NULL>, <NULL>)

I have created migration as

            $table->bigInteger('dept_id')->unsigned()->nullable(); 
            $table->bigInteger('room_id')->unsigned()->nullable(); 
            $table->bigInteger('roll_id')->unsigned()->nullable();
            $table->unique(['dept_id', 'room_id','roll_id']);

I am using MsSQL 2017 as the database. It is now allowing to have null value in these unique columns for more than once. What I am missing?

ssquare started a new conversation Data Missing ERROR!!

I am trying to insert data to the table as follows:

FEC::create($fec_arr);

dd($fec_arr) returns

array:22 [
  "cmte_id" => "C00343863"
  "amndt_ind" => "N"
  "rpt_tp" => "Q3"
  "transaction_pgi" => "P"
  "image_num" => "27990795810"
  "transaction_tp" => "15"
  "entity_tp" => "IND"
  "name_voter" => "HOETGER, JACQUELINE Middle_ini Midlle mr."
  "mailing_address_city" => "FENTON"
  "mailing_address_state" => "MI"
  "mailing_address_zip" => "48430"
  "employer" => "SELF"
  "occupation" => "MOTT MEDIA"
  "donation_date" => "2007-08-30 12:00:00"
  "donation_id" => "A-C39094"
  "fec_federal_num" => "307489"
  "fec_memo_cd" => ""
  "fec_memo_text" => ""
  "fec_sub_id" => "4.10E+18"
  "name_last" => "HOETGER"
  "base_voter_id" => 5
  "created_by" => 1
]

Columns List in FEC Modal

       [cmte_id]
      ,[amndt_ind]
      ,[rpt_tp]
      ,[transaction_pgi]
      ,[image_num]
      ,[transaction_tp]
      ,[entity_tp]
      ,[name_last]
      ,[name_voter]
      ,[mailing_address_city]
      ,[mailing_address_state]
      ,[mailing_address_zip]
      ,[employer]
      ,[occupation]
      ,[donation_date]
      ,[donation_amount]
      ,[donation_id]
      ,[fec_other_id]
      ,[fec_federal_num]
      ,[fec_memo_cd]
      ,[fec_memo_text]
      ,[fec_sub_id]
      ,[base_voter_id]
      ,[created_by]
      ,[updated_by]
      ,[deleted_at]
      ,[created_at]
      ,[updated_at]

I am getting error as Data Missing. What I am doing wrong here?

23 Oct
1 month ago

ssquare left a reply on Laravel Execute Stored Procedure Taking More Time Than From SSMS

An invalid statement option was specified.

        $dbh = DB::connection()->getPdo();
        $sth = $dbh->prepare("EXEC [spBaseVoterIndex] ?,?,?,?",[$order, $dir, (int)$pagenum, (int)$pagesize]);
        $posts  = $sth->execute();

Also, I have already used NOCOUNT ON on stored procedure, should I used here too or can i igonre here if I have included it on stored procedure

ssquare started a new conversation Laravel Execute Stored Procedure Taking More Time Than From SSMS

I am using laravel 5.6 and MSSQL as database. I have table with records more than 100m+ rows. So whenever I execute a stored procedure through SSMS it takes around 1 sec but if I execute it through laravel execute it, this query time increases by 7-8 times.

My laravel code here looks like:


        $time_start2 = microtime(true);

        $posts = DB::select('EXEC [spBaseVoterIndex] ?,?,?,?',
                [
                    $order, $dir, (int)$pagenum, (int)$pagesize
                ]);
        
        $time_end2 = microtime(true);
        $execution_time2 = $time_end2 - $time_start2;

Is there any way to know what is Laravel doing it in the back or could anyone explain about the background stuffs included here. What might be taking the time and how can I minimize it.

17 Oct
1 month ago

ssquare left a reply on Laravel Queue Not Working As Expected

@d9705996 I am using laravel 5.6

ssquare started a new conversation Laravel Queue Not Working As Expected

What I have done so far:

  1. Updated queue driver to database in .env
  2. My mail controller function looks like:
    public function sendEmail()
    {
       $emailJob = (new SendEmailJob())->delay(Carbon::now()->addSeconds(3));
       dispatch($emailJob);
        exit();
    }
  1. SendEmailJob handle
    public function handle()
    {
        Mail::to('[email protected]')->send(new SendMailable());
        echo 'email sent';
    }
  1. SendMailable Mail has following
    public function build()
    {
        return $this->view('emails.ownership');
    }

I want to send mail almost instantly after hitting the url. As I am running php artisan queue:listen with delay of 3 seconds it takes a lot of time before any action. I can see some data on jobs table with 0 attempts.

After long time, following error popup in command window

   Symfony\Component\Process\Exception\ProcessTimedOutException  : The process ""C:\wamp64\bin\php\php7.2.10\php.exe" "artisan" queue:work  --once --queue="default" --delay=0 --memory=128 --sleep=3 --tries=0" e
xceeded the timeout of 60 seconds.

  at C:\wamp64\www\project\vendor\symfony\process\Process.php:1154
    1150|
    1151|         if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
    1152|             $this->stop(0);
    1153|
  > 1154|             throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
    1155|         }
    1156|
    1157|         if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
    1158|             $this->stop(0);

  Exception trace:

  1   Symfony\Component\Process\Process::checkTimeout()
      C:\wamp64\www\project\vendor\symfony\process\Process.php:383

  2   Symfony\Component\Process\Process::wait()
      C:\wamp64\www\project\vendor\symfony\process\Process.php:202

By, the way mail can be sent directly without this queue stuff. Also, is this compulsory to run php artisan queue:listen? How am I supposed to run this in server with no shell access?

11 Oct
1 month ago

ssquare started a new conversation Catch Error If Arise On A Loop But Continue Ro Process Other Data From The Loop.

Scenarion:

I am trying to dump data from csv file to MsSQL database. My code is as:

        /*here skip is just 0 or 1 if skip is 0 later that mapped row will be ignored. Map data contains index array which will later used to map csv column to database column*/

        $limit = $this->service->getSettingsNameValue('chunk_limit');
            $skip = $request->skip;
            $map_data = $request->row;

    /*Just reading csv file. Have used csv league*/
        $db_header_obj = new Sos_contribution();
            $db_header = $db_header_obj->getTableColumns();
            $csv_file_path = storage_path('app/files/sos_contribution/').$request->filename;
            $csv = Reader::createFromPath($csv_file_path, 'r');
            $csv->setOutputBOM(Reader::BOM_UTF8);
            $csv->addStreamFilter('convert.iconv.ISO-8859-15/UTF-8');
            $csv->setHeaderOffset(0); //set the CSV header offset
            $csv_header = $csv->getHeader();    

            $rec_arr = array();
            $records = array();
            $records_arr = array();

            $stmt = (new Statement())
            ->offset($offset)
            ->limit($limit)
            ;

            $records = $stmt->process($csv);

            foreach ($records as $record) 
            {
                $rec_arr[] = array_values($record);
            }

            $records_arr = $this->service->trimArray($rec_arr);

            if(count($records_arr)>0)
            {
                foreach($records_arr as $ck => $cv){

                    $sos_contribution_arr = array();
                    foreach ($map_data as $mk => $mv) {
                        if(!isset($skip[$mk])){

                                $data_type = $this->service->getDatabaseColumnType($this->table,$mv);
                                if($data_type == 'date' || $data_type == 'datetime' || $data_type == 'timestamp'){
                /*just little piece of formatting of datetime*/
                                    $datetime =  (array)$cv[$mk];
                                    $dt = array_shift($datetime);
                                    $dt = date('Y-m-d h:i:s', strtotime($dt));
                                    $sos_contribution_arr[$mv] = $dt;
                                }else{
                                    $sos_contribution_arr[$mv] = $cv[$mk];
                                }   

                        }
                    }


        /*CATCH ERROR HERE*/
                    Sos_contribution::where('voter_state_id',$sos_contribution_arr['voter_state_id'])
                        ->update($sos_contribution_arr);

                   
              }
        }

Problem:

As I have huge csv file, there might be some typo errors in some column for example here example having some string character in integer column.

So, for example if there are 10 rows and there is an sql error for row 2. this means there is an string character mapped to int column. In that case, it just throws error and halt the process.

But, what I want is not to halt the process, instead record the row number and continuing other row. In this case, store 2 in a variable and continue processing 3-10 and later return that row number.

Is that possible?

What might be the best way to deal with this as later I want to queue this job and later send email to the owner after the completion of job with failed row number.

Example error: SQLSTATE[22018]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value 'abx' to data type tinyint.

24 Sep
2 months ago

ssquare started a new conversation Obtain Result In Object Type And In Single Level

My MSSQL procedure

CREATE PROCEDURE PROCEDURE_NAME
AS BEGIN
    SELECT COUNT(*) FROM users
END

Currently calling as $totalData = DB::select('EXEC PROCEDURE_NAME');

and getting result in

<pre>Array
(
    [0] => stdClass Object
        (
            [] => 200000
        )

)
</pre>

Instead of this how can I get 200000 directly in $totalData.

21 Sep
2 months ago

ssquare started a new conversation Introducing FOREIGN KEY Constraint 'my_list_user_user_id_foreign' On Table 'my_l Ist_user' May Cause Cycles Or Multiple Cascade Paths. Specify ON DELETE NO ACTION Or ON UPDATE NO ACTION, Or Modify Other FOREIGN KEY Constraints.

I have just moved from mysql to MSSQL server. But, if I try to run migration I received error as follows. [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Introducing FOREIGN KEY constraint 'my_list_user_user_id_foreign' on table 'my_l ist_user' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. (SQL: alter table "my_list_user" add constrai nt "my_list_user_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade)

My migration schema looks lie belows

Users

        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->integer('organization_id')->unsigned();
            $table->foreign('organization_id')->references('id')->on('organizations');
            $table->rememberToken();
            $table->softDeletes();
            $table->timestamps();
        });

My_Lists

        Schema::create('my_lists', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title',255); 
            $table->text('description'); 

            $table->unsignedInteger('created_by');
            $table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');

            $table->softDeletes();
            $table->timestamps();
        });

My_list_user

        Schema::create('my_list_user', function (Blueprint $table) {
            $table->integer('my_list_id')->unsigned()->index();
            $table->foreign('my_list_id')->references('id')->on('my_lists')->onDelete('cascade');


            $table->integer('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->primary(['my_list_id', 'user_id']); 
         });

Is that MS SQL does not support even a single level of cascade? How can I solve this?

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

Thank you actually I need to make change to SQL server authentication. That is the key what I am missing. Also, as you suggest I need to place drive on both ext folder.

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@staudenmeir I have an update now. If I test with following code.

<?php
$serverName = "(local)";
$connectionInfo = array( "Database"=>"kpi_db","UID"=>"root", "PWD"=>"123456");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>`

It shows following error

Connection could not be established. Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'root'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'root'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'root'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'root'. ) )

But if I tried with

<?php
$serverName = "DESKTOP-H9OGJE5\MSSQLSERVER";
$connectionInfo = array( "Database"=>"kpi_db","UID"=>"root", "PWD"=>"123456");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>`

I used to got different error Connection could not be established. Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 87 [code] => 87 [2] => [Microsoft][ODBC Driver 13 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. [message] => [Microsoft][ODBC Driver 13 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired [message] => [Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 87 [code] => 87 [2] => [Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

Could you get some clue?

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@staidenmeir

DB_CONNECTION=sqlsrv
DB_HOST=DESKTOP-H9OGJE5\MSSQLSERVER
DB_PORT=1433
DB_DATABASE=kpi_db
DB_USERNAME=root
DB_PASSWORD=123456

and

DB_CONNECTION=sqlsrv
DB_HOST=DESKTOP-H9OGJE5\MSSQLSERVER
DB_PORT=1433
DB_DATABASE=kpi_db
DB_USERNAME=sa
DB_PASSWORD=

I have checked with both of this combination and with user root and sa both times gives same result for with port it also shows port and if no port provided it won't display port

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@staudenmeir I have worked with that too. But with no success. Still returning.

"sqlsrv:Server=DESKTOP-H9OGJE5\MSSQLSERVER;Database=kpi_db"

If you could, I could also screen share with team viewer or so

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@staudenmeir

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:MQ/MXLKOABVwvWjD3G9TgX1v4BO/+bWCez06cuzhYv8=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=sqlsrv
DB_HOST=DESKTOP-H9OGJE5\MSSQLSERVER
DB_PORT=1433
DB_DATABASE=kpi_db
DB_USERNAME=sa
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=database

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@technosml ```$serverName = "DESKTOP-H9OGJE5\MSSQLSERVER"; //serverName\instanceName $connectionInfo = array( "Database"=>"kpi_db", "UID"=>"sa", "PWD"=>""); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established. "; }else{ echo "Connection could not be established. "; die( print_r( sqlsrv_errors(), true)); } ?>`


I got above error. I have created database on sql server using (local). And I don't know I have which username and password on sqlserver I am using username 'sa' and black password as suggesting as default one.

ssquare left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

@staudenmeir Got following error

SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. (SQL: select top 1 * from [settings] where [name] = site_title and [settings].[deleted_at] is null)

ssquare started a new conversation SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

I am just trying to migrate my laravel to sql server. I have installed Miscrosoft SQL Server. I have downloaded SQL server developer version and make default basic installation.

I am using wamp 64 with php 7.2.4. I have added two extensions in php.ini after I copied them inside wamp64/bin/php/php7.2.4/ext/

extension=php_pdo_sqlsrv_72_ts_x64 extension=php_sqlsrv_72_ts_x64

Now, I can see pdo_sqlsrv in phpinfo.

I have created a database in MSSQL and updated .env file as

DB_CONNECTION=sqlsrv
DB_HOST=DESKTOP-H9OGJE5\MSSQLSERVER
DB_PORT=1433
DB_DATABASE=kpi_db
DB_USERNAME=sa
DB_PASSWORD=

But, unfortunately I am getting this error when I tried to load. Also, I have tried to migrate through artisan command but with no success

   Illuminate\Database\QueryException  : could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)

  at C:\wamp64\www\project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   Doctrine\DBAL\Driver\PDOException::("could not find driver")
      C:\wamp64\www\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:50

  2   PDOException::("could not find driver")
      C:\wamp64\www\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:46

  Please use the argument -v to see more details.

13 Sep
2 months ago

ssquare started a new conversation Jquery Datatable Throws Error As Soon As I Implement Laravel Pagination Links

@foreach($users as $kv => $vv)
                                    <tr>
                                        <td>{{ $vv -> name}}</td>
                                        <td>{{ $vv-> address}}</td>
                                        <td>{{ city }}</td>
                                        <td> Actions </td>
                                    </tr>
                                    @endforeach
                                    <tr>
                                        <td colspan="100%"> 
                                            {{ $users->links() }}
                                        </td>
                                    </tr>

Error: Cannot set property '_DT_CellIndex' of undefined

After this error, it also does not show datatable's search, sorting and filtering. But as soon as I remove {{$users -> links }} everything works fine.

What I am trying?

I am trying to implement laravel pagination with jquery datatables. As, even serverside jquery datatables took quite long time to process around 30M data. Is there any way to use laravel pagination but jquery datatable's sort, search, and filter?

Any suggestion will be appreciated.

29 Aug
3 months ago

ssquare started a new conversation Create A New Table Or Store In Same

Ok, I have data about different persons. Lets' say people from different states. One states have around 10-15M rows of data. Now, here which one is suitable is it good to make each table for each state or to insert all data in same table.

Could you also explain me the pros and cons of both method.

24 Aug
3 months ago

ssquare left a reply on Malformed UTF-8 Characters, Possibly Incorrectly Encoded

Ok, I have fixed this. Instead of fixing before inserting to database. I convert the charset during reading csv file. So, after that, even on beginning

Dummy Name �zilhis was replaced to Özil

ssquare left a reply on Malformed UTF-8 Characters, Possibly Incorrectly Encoded

@sirik Yeah, that's my exact requirement. But unfortunately, this also doe snot work.

I have tried to print.

{
         p($cv[$mk]);
        $contribution_data_arr[$mv] = preg_replace("/&([a-z])[a-z]+;/i", "", htmlentities($cv{$mk}));;
}
p($contribution_data_arr);

Here before preg_replace: Dummy Name �zilfter replace:

Array
(
    [name] =>              //Actually here needs to be displayed Ozil
    [home_street_address_1] => YUMA STREET
)
23 Aug
3 months ago

ssquare left a reply on Malformed UTF-8 Characters, Possibly Incorrectly Encoded

@Sirik Your solutions work with error but Instead It is replacing "Özil" to "zil". This is not what I am seeking.

ssquare left a reply on Malformed UTF-8 Characters, Possibly Incorrectly Encoded

@tray I am currently using 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci'. Instead of changing, is not there any way to encode it and decode it later querying from database.

ssquare started a new conversation Malformed UTF-8 Characters, Possibly Incorrectly Encoded

I am tryin to insert data to database using csv. And for this I am doing something like below in a loop

        $data_arr[$mv] = $cv[$mk]; 

Here, there are latin characters on some field. So, it might be displaying this error. So, far I have tried some thing like


$data_arr[$mv] = json_encode($cv[$mk], JSON_UNESCAPED_UNICODE); 

But doing this, changing even integer value to string and that field with latin character is turning empty. How can I tackle this problem.

20 Aug
3 months ago

ssquare started a new conversation Need Help To Convert General Sql Query To Query Builder

Hello guys, my following query is running well. But I am finding it quite difficult to use it as query builder. I am just willing to make equivalent query builder of following:

       /*DONATION RANGE*/
        $donation_range = '1 = 1';
        if($request->donation_range_checkbox){
            $donation_range = "(D.donation_amount >= '".$request->min_donation_amount."' AND D.donation_amount <= '".$request->max_donation_amount."')";
        }else{
            if(trim($request->donation_amount) != ''){
                $donation_range = "D.donation_amount = '".$request->donation_amount."'";    
            }
        }

        /*DURATION*/
        $duration = '1 = 1';
        if($request->period != 'all' ){
            if($request->period == 'custom'){
                $start_date = $request->datestart;
                $end_date = $request->dateend;
                $start_date =  date('Y-m-d', strtotime($request->datestart) );
                $end_date =  date('Y-m-d', strtotime($request->dateend) );
                $duration = "D.donation_date between '".$start_date."' AND '".$end_date."' ";
            }else{
                $duration = "D.donation_date > DATE_SUB('".date('Y-m-d')."', INTERVAL '".$request->duration."' DAY)";
            }
        }

        /*STATE FILTER*/
        $state_filter = '1 = 1';
        $state_arr = array_map( 'trim', explode( ",",$request->state ) );
        $state_arr_str = implode("','",$state_arr);
        if(trim($state_arr_str) != '')
        {
            $state_filter = "B.home_address_state IN ('".$state_arr_str."') OR B.mailing_address_state IN ('".$state_arr_str."')";
        }

        /*CITY FILTER*/
        $city_filter = '1 = 1';
        $city_arr = array_map( 'trim', explode( ",",$request->city ) );
        $city_arr_str = implode("','",$city_arr);
        if(trim($city_arr_str) != '')
        {
            $city_filter = "B.home_address_city IN ('".$city_arr_str."') OR B.mailing_address_city IN ('".$city_arr_str."')";
        }

        /*STREET FILTER*/
        $street_filter = '1 = 1';
        $street_arr = array_map( 'trim', explode( ",",$request->street ) );
        $street_arr_str = implode("','",$street_arr);
        if(trim($street_arr_str) != '')
        {
            $street_filter = "B.home_street_address_1 IN ('".$street_arr_str."') OR B.home_street_address_2 IN ('".$street_arr_str."') OR B.home_street_address_3 IN ('".$street_arr_str."') OR B.mailing_street_address_1 IN ('".$street_arr_str."') OR B.mailing_street_address_2 IN ('".$street_arr_str."') OR B.mailing_street_address_3 IN ('".$street_arr_str."')";
        }

        /*HOME DIRECTION*/
        $home_direction_filter = '1=1';
        if(trim($request->direction) != '')
        {
            $home_direction_filter = "C.home_direction = '".$request->direction."'";
        }

        /*HOUSE NUMBER*/
        $house_number = '1 = 1';
        if($request->house_number_checkbox){
            $house_number = "(C.home_house_number >= '".$request->min_house_number."' AND C.home_house_number <= '".$request->max_house_number."')";
        }else{
            if(trim($request->house_number) != ''){
                $house_number = "C.home_house_number = '".$request->house_number."'";
            }
        }

        /*ZIP CODE FILTER*/
        $zip_code_filter = '1 = 1';
        $zip_code_arr = array_map( 'trim', explode( ",",$request->zip_code ) );
        $zip_code_arr_str = implode("','",$zip_code_arr);
        if(trim($zip_code_arr_str) != '')
        {
            $zip_code_filter = "B.home_address_zip IN ('".$zip_code_arr_str."') OR B.home_address_zip_plus IN ('".$zip_code_arr_str."') OR B.mailing_address_zip IN ('".$zip_code_arr_str."') OR B.mailing_address_zip_plus IN ('".$zip_code_arr_str."')";
        }

        /*GENDER*/
        $gender_filter = '1=1';
        if(trim($request->gender) != '')
        {
            $gender_filter = "B.gender LIKE '".$request->gender."%'";
        }

        /*AGE RANGE*/
        $age = '1 = 1';
        if($request->age_checkbox){
            if($request->min_age){
                $max_birth_year = date('Y') - $request->min_age; //year will be max as opposed to age
            }else{
                $max_birth_year = date('Y');
            }

            if($request->max_age){
                $min_birth_year = date('Y') - $request->max_age; //year will be min as opposed to age
            }else{
                $min_birth_year = 0;
            }

            $age = "(B.birth_year >= '".$min_birth_year."' AND B.birth_year <= '".$max_birth_year."')";
        }else{
            if($request->age){
                $birth_year = date('Y') - $request->age;
                $age = "B.birth_year = '".$birth_year."'";
            }
        }

        /*VOTER PARTY*/
        $party_filter = '1=1';
        if(trim($request->party) != '')
        {
            $party_filter = "B.voter_party LIKE '".$request->party."%'";
        }

        /*TAGS*/
        $tags_filter = '1=1';
        if(trim($request->tags) != '')
        {
            $tags_filter = "N.note_types LIKE '%".$request->tags."%'";
        }

        /*BASE_VOTER_MY_LIST*/
        $my_list_filter = "B.id NOT IN (SELECT M.base_voter_id from base_voter_my_list M where M.my_list_id = '".$my_list_id."')";
        

        $sqlx = "SELECT DISTINCT B.* from base_voter B LEFT OUTER JOIN 
        contribution_data R ON B.contribution_data_table_id = R.id LEFT OUTER JOIN 
        contribution_donation D ON R.id = D.contribution_data_id LEFT OUTER JOIN
        city_voter C ON B.city_voter_table_id = C.id LEFT OUTER JOIN
        notes N ON B.id = N.base_voter_id LEFT OUTER JOIN
        base_voter_my_list M ON B.id = M.base_voter_id
        WHERE (".$donation_range.") AND (".$state_filter.") AND (".$city_filter.") AND (".$street_filter.") AND (".$home_direction_filter.") AND (".$house_number.") AND (".$zip_code_filter.") AND (".$gender_filter.") AND (".$age.") AND (".$party_filter.") AND (".$tags_filter.") AND (".$my_list_filter.")
         ";
17 Aug
3 months ago

ssquare started a new conversation Add Content Type Text/html In Sendgrid Mail

I am following https://sendgrid.com/docs/Integrate/Frameworks/laravel.html this tutorial to send mail using sendgrid. But, I am unable to figure out adding content type text/html how could I do that. Could anyone guide me through this?