anp24

anp24

Member Since 11 Months Ago

Experience Points 1,580
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.

18 Dec
10 months ago

anp24 started a new conversation SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

I have 3 tables

applicant_profiles - having id as primary key user_profiles - having id as primary key users - having applicant_id and user_id as Foreign keys , now if I insert into the users table , I encountered the following error.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - FK_Applicant_ID

I am sending applicant_id as 0 and user_id from user_profiles table

11 Dec
11 months ago

anp24 started a new conversation Model Relationships

I have two models - applicant_profiles and User. one user has only one profile. I have to set the relationship, Once I set the relationship in model, do I have to also set relationship by going to mysql and setting the relationship in respective tables as "applicant_profiles" and "users"?

09 Dec
11 months ago

anp24 left a reply on Disable Blade View Button From Controller

@tykus , I want the following property of button to be set

disabled="disabled"

from controller

07 Dec
11 months ago

anp24 left a reply on Disable Blade View Button From Controller

@tykus from controller how do I send this value

anp24 left a reply on Eloquent Query In Laravel 5.5

any body has the solution for this error

06 Dec
11 months ago

anp24 left a reply on Eloquent Query In Laravel 5.5

@mvd , yes this column is available in the database table

anp24 left a reply on Eloquent Query In Laravel 5.5

I have again updated the query , still the same error

anp24 left a reply on Eloquent Query In Laravel 5.5

I have updated the query

anp24 left a reply on Eloquent Query In Laravel 5.5

I have added the table name, but the same error

anp24 started a new conversation Eloquent Query In Laravel 5.5

I have written the following query to fetch records from database

 $query3 = DB::table('rbac_modules')->select('mr_role_id as 0', 'mr_role_nm as NULL',
          'mr_user as null','rbac_forms.fm_form_id','rbac_forms.fm_form_nm',' 
          rbac_forms.fm_form_type','rbac_modules.mm_module_id','rbac_modules.mm_module_nm',
          'mar_read as 0','mar_write as 0','mar_modify as 0','mar_delete as 0','mar_show_on_menu as 0')
          ->join('rbac_forms', 'rbac_modules.mm_module_id', '=', 'rbac_forms.fm_form_module_id')
          ->where([
    ['rbac_forms.fm_status', '=', '1'],
    ['rbac_modules.mm_status', '=', '1'] ])
          ->whereNotIn('fm_form_id', function($query) 
          {
          $query->select('rbac_forms.fm_form_id')
         ->from('rbac_access_rights')
         ->join('rbac_roles', 'rbac_access_rights.mar_role_id', '=', 'rbac_roles.mr_role_id')
          ->join('rbac_modules','rbac_modules.mm_module_id', '=', 'rbac_forms.fm_form_module_id')
          ->join('rbac_forms', 'rbac_modules.mm_module_id', '=', 'rbac_forms.fm_form_module_id')
          ->where([
    ['rbac_forms.fm_status', '=', '1'],
    ['rbac_modules.mm_status', '=', '1'],
    ['mr_role_id', '=', $_POST['rolename']]
    ]);
          })
          ->get();

Now It is giving me error

Column not found: 1054 Unknown column 'mr_role_id' in 'field list' What is wrong with this query

05 Dec
11 months ago

anp24 started a new conversation Disable Blade View Button From Controller

How do I disable Blade View Button from Controller

anp24 started a new conversation Grid Display On Drop Down Selection

My drop down is in blade.php file. I want the display of grid in the same blade.php with database values on the selection of drop down from blade.php file. With the drop down , I intend to get the ID and with this ID , I will create query to get the values into grid. In C# , the event is 'OnSelectedIndexChanged' , what is the equivalent in Laravel/PHP

01 Dec
11 months ago

anp24 left a reply on Laravel 5.5 Inbuilt Login For Different Roles

Also the same login , with user id for superadmin and other roles and email address for login with "applicant" role

anp24 left a reply on Laravel 5.5 Inbuilt Login For Different Roles

Also I have one "users" table, that is the built-in table

anp24 left a reply on Multi Auth In Laravel 5.5

@ekhlas , the link given is for laravel 5.2.2 , I require link for laravel 5.5

anp24 started a new conversation Laravel 5.5 Inbuilt Login For Different Roles

I have defined one more role 'superadmin' under guards in auth.php as shown below.

  'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
        
        'superadmin' => [
            'driver' => 'session',
            'provider' => 'superadmins',
        ],
        
        'superadmin-api' => [
            'driver' => 'token',
            'provider' => 'superadmins',
        ],
    ],

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        
         'superadmins' => [
            'driver' => 'eloquent',
            'model' => App\SuperAdmin::class,
        ],

    ],

Now how I can I change the file - AuthenticatesUsers.php under

\vendor\laravel\framework\src\Illuminate\Foundation\Auth to authenticate one more guard. I am new to laravel

anp24 started a new conversation Multi Auth In Laravel 5.5

I want to set up multi auth in Laravel 5.5

I have already setup - php artisan make:auth

There are the following roles - superadmin, applicant and 2 more.

Please advise what files I need to change and include. I am new to laravel

anp24 left a reply on Return The Value Per Row Grid Value In View-components/grids

I am new to laravel , please help me

anp24 left a reply on Return The Value Per Row Grid Value In View-components/grids

please help as I am stuck on this issue

anp24 started a new conversation Return The Value Per Row Grid Value In View-components/grids

I have used the following code to return the value to the view-components/grids - setValueCalculator, but the below code is setting the same value in all rows of the grid - either the first row value of database table or the last value of database table.


public function getzonename()
    {
        $result=array();
        $zoneids = state_masters::all(['zone_id']);
        $array_length = count($zoneids);
        $iteration    = 0;
        $zonenames = array();
        $idval="";
        $count = 0;
                          
        while($iteration < $array_length)
        {
            $idval = $zoneids[$iteration];
            $zonenames[] = DB::select('select zone_name from zone_masters where id = ?',[$idval->zone_id]);
                                        
            $iteration++;
            
        }
    
          return $zonenames;
        
    }

--------------------------------------------------------------------------------------------------------

public function shownewgrid(Request $request)
    {
        $provider = new EloquentDataProvider(state_masters::class);
        
        
        
           $input = new InputSource($_GET);
           
        $columns = [
                        'Zone Name' => new Column('Zone Name'),
                        'state_name' => new Column('state_name'),
                        'id' => new Column('Update'),
                       'deleterec' => new Column('Delete record'),
                         new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
                         new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
                         new CsvExport($input->option('csv'))
                        
                     ];
                    
              $grid = new Grid( $provider, $columns);
              
            
        
                $columns['Zone Name']->setValueCalculator(function($row)
                {
                     $row = StateController::getzonename();
                        
                     for ($i=0;$i<sizeof($row);$i++) 
                     {
                        
                        return $row[$i][0]->zone_name;
                                     } 
                    
                });
          
          
            $columns['id']->setValueFormatter(function ($id, $row) 
            {
            return "<a href='". url('/editstaterecord')."/{$row->id}'>Update</a>";  
            })
            ->getDataCell()
            ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
            ->setAttribute('style', 'cursor:pointer');
            
           $columns['deleterec']->setValueFormatter(function ($id, $row) 
           {
             return "<a href='". url('/deletestaterecord')."/{$row->id}'>Delete</a>";
           })
           ->getDataCell()
        
           ->setAttribute('onclick', 'return confirm("Are you sure you want to delete this item?");')
           ->setAttribute('style', 'cursor:pointer');
           
         
            //  but also you can add some styling:
            $customization = new BootstrapStyling();
            $customization->apply($grid);
            
            $items = zone_masters::all(['id', 'zone_name']);
         
              return view('masters.state', compact('grid','items'));
    }

30 Nov
11 months ago

anp24 left a reply on Return To SetValueCalculator In View-components/grids

is there no body to answer my question?

anp24 left a reply on Return To SetValueCalculator In View-components/grids

Please answer my question - how can I set the values from database table to the grid row using setValueCalculator

anp24 started a new conversation Return To SetValueCalculator In View-components/grids

How do I return value to the setValueCalculator so that value is set for each row of the grid and not all the rows with database table first row or last row.

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

Please at least ans the question regarding returning the value of setValueCalculator

29 Nov
11 months ago

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

Please some one answer this, how do I return the value to setValueCalculator so that each row of the grid is set to their respective values and not the first or last values

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

@divanoli

I have now changed the code as shown below

$provider = new EloquentDataProvider(state_masters::class);
        
           $input = new InputSource($_GET);
           
        $columns = [
                        'Zone Name' => new Column('Zone Name'),
                        'state_name' => new Column('state_name'),
                        'id' => new Column('Update'),
                       'deleterec' => new Column('Delete record'),
                         new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
                         new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
                        //new ColumnSortingControl('id', $input->option('sort')),
                        // new FilterControl('id', FilterOperation::OPERATOR_LIKE, $input->option('id')),
                         new CsvExport($input->option('csv'))
                        
                     ];
        
                                    $items = array();
                                    $result=array();
                                   $columns['Zone Name']
                                   ->setValueCalculator(function ($zonename) 
                                   {
                                       $zoneids = state_masters::all(['zone_id']);
                                       $array_length = count($zoneids);
                                       $iteration    = 0;
                                       $zonenames = array();
                                     
                                       while($iteration < $array_length)
                                       {
                                            $idval = $zoneids[$iteration];
                                            $zonenames[] = DB::select('select zone_name from zone_masters where id = ?',[$idval->zone_id]);
                                            
                                      $iteration++;
                                        }
                                        
                                        
                                       foreach($zonenames as $zonename)
                                       {
                                            echo "</BR>";
                                          echo $zonename[0]->zone_name;
                                           //$result=$zonename[0]->zone_name;
                                        
                                            echo "</BR>";
                                       }
                                        
                                          // return $result;
                                        
                                     });
                        
              
              $grid = new Grid( $provider, $columns, [] );
          
            $columns['id']->setValueFormatter(function ($id, $row) {
            return "<a href='". url('/editstaterecord')."/{$row->id}'>Update</a>";  
          })
            ->getDataCell()
            ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
            ->setAttribute('style', 'cursor:pointer');
            
           $columns['deleterec']->setValueFormatter(function ($id, $row) 
           {
             return "<a href='". url('/deletestaterecord')."/{$row->id}'>Delete</a>";
           })
           ->getDataCell()
        
         //->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
           ->setAttribute('onclick', 'return confirm("Are you sure you want to delete this item?");')
           ->setAttribute('style', 'cursor:pointer');
           
         
            //  but also you can add some styling:
            $customization = new BootstrapStyling();
            $customization->apply   ($grid);
            
            $items = zone_masters::all(['id', 'zone_name']);
         
              return view('masters.state', compact('grid','items'));

When I echo $zonename[0]->zone_name, it is showing me all the zone names, but if I return the value to setValueCalculator , it is only showing me first or last values of table

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

@divanoli

If have to write $this->$items[$zonename->zone_name]; , then I can only receive the value

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

If I write the above code, return $this->$items[$zonename->zone_name]; will return the last value from the tables

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

Controller Code is given as below. Values are now displaying , but when I return it to the setValueCalculator it is either returning the first value or last value of the table


$provider = new EloquentDataProvider(state_masters::class);
        
        
        
           $input = new InputSource($_GET);
        
        
        $columns = [
                        'Zone Name' => new Column('Zone Name'),
                        'state_name' => new Column('state_name'),
                        'id' => new Column('Update'),
                       'deleterec' => new Column('Delete record'),
                         new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
                         new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
                        //new ColumnSortingControl('id', $input->option('sort')),
                        // new FilterControl('id', FilterOperation::OPERATOR_LIKE, $input->option('id')),
                         new CsvExport($input->option('csv'))
                        
                      
                     ];
        
                       $items = array();
                       
                                   $columns['Zone Name']
                                   ->setValueCalculator(function ($items) 
                                   {
                                       $zoneids = state_masters::all(['zone_id']);
                                      foreach($zoneids as $zoneid)
                                       {
                                         echo "the value of zone id is   ".$zoneid->zone_id;
                                           echo "</BR>";
                                         $zonenames = DB::select('select zone_name from zone_masters where id = ?',[$zoneid->zone_id]);
                              
                                           foreach($zonenames as $zonename)
                                            {
                                         
                                            $this->$items[$zonename->zone_name] = $zonename->zone_name;
                                            echo "the zone name is    ".$this->$items[$zonename->zone_name];
                                             echo "</BR>";
                                            
                                            }
                                             
                                         }
                                           
                                     });
                        
              
              $grid = new Grid( $provider, $columns,
          
          [
          
       
        
       
          
          ]
          
          );
          
          
          
                
            
            
            
            $columns['id']->setValueFormatter(function ($id, $row) {
            return "<a href='". url('/editstaterecord')."/{$row->id}'>Update</a>";
            
            
            
          })
            ->getDataCell()
            ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
            ->setAttribute('style', 'cursor:pointer');
            
            
            
           $columns['deleterec']->setValueFormatter(function ($id, $row) 
           {
             return "<a href='". url('/deletestaterecord')."/{$row->id}'>Delete</a>";
           })
           ->getDataCell()
        
         //->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
           ->setAttribute('onclick', 'return confirm("Are you sure you want to delete this item?");')
           ->setAttribute('style', 'cursor:pointer');
           
         
            //  but also you can add some styling:
            $customization = new BootstrapStyling();
            $customization->apply   ($grid);
            
            $items = zone_masters::all(['id', 'zone_name']);
         
              return view('masters.state', compact('grid','items'));
    }

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

@divanoli ,

still error is generated in the following line

$valq[] = $zonename->zone_name;

Method ViewComponents\Grids\Grid::__toString() must not throw an exception, caught ArgumentCountError: Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in C:\xampp\htdocs\CPMS\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasAttributes.php on line 525 and exactly 2 expected

28 Nov
11 months ago

anp24 left a reply on Setting The Grid Column Value From Database (view-components/grids)

someone please help me, its urgent!!!!!

anp24 started a new conversation Setting The Grid Column Value From Database (view-components/grids)

By default the grid column has numeric values of ids coming from database , but for better understanding we want the names instead corresponding to those ids from database. We are setting the value using setValueCalculator function in grid view , also looping through the data values from the database, but it is showing a single value instead.

Following is the code from controller


$provider = new EloquentDataProvider(state_masters::class);
        
        $input = new InputSource($_GET);
        
    
        
        
        $columns = [
                        'Zone Name' => new Column('Zone Name'),
                        'state_name' => new Column('state_name'),
                        'id' => new Column('Update'),
                       'deleterec' => new Column('Delete record')
                     ];
        
        
        
                
                
                
                        
                          
                        $columns['Zone Name']
                        ->setValueCalculator(function ($valq) 
                        {
                          $zoneids = state_masters::all(['zone_name']);
                             foreach($zoneids as $zoneid)
                         {
                           echo "the value of zone id is   ".$zoneid->zone_name;
                    
                            $zonenames = DB::select('select zone_name from zone_masters where id = ?',[$zoneid->zone_name]);
                              foreach($zonenames as $zonename)
                              {
                                  $valq = $zonename->zone_name;
                                   echo "the value of zone name in valq is   ".$valq;
                                  echo "</BR>";
                                   return $valq;
                              }
                        }
                         
                        });
                        
              
              $grid = new Grid( $provider, $columns,
          
          [
          
        new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
        new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
        new ColumnSortingControl('id', $input->option('sort')),
        new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
        new CsvExport($input->option('csv'))
          
          ]
          
          );
          
          
          
                
            
            
            
            $columns['id']->setValueFormatter(function ($id, $row) {
            return "<a href='". url('/editstaterecord')."/{$row->id}'>Update</a>";
            
            
            
          })
            ->getDataCell()
            ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
            ->setAttribute('style', 'cursor:pointer');
            
            
            
           $columns['deleterec']->setValueFormatter(function ($id, $row) 
           {
             return "<a href='". url('/deletestaterecord')."/{$row->id}'>Delete</a>";
           })
           ->getDataCell()
        
         //->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
           ->setAttribute('onclick', 'return confirm("Are you sure you want to delete this item?");')
           ->setAttribute('style', 'cursor:pointer');
           
         
            //  but also you can add some styling:
            $customization = new BootstrapStyling();
            $customization->apply   ($grid);
            
            $items = zone_masters::all(['id', 'zone_name']);
         
              return view('masters.state', compact('grid','items'));

anp24 left a reply on Pagination , Page Size Select Not Displaying In View-components/grids

KodeCept , How I Do the refactoring?

anp24 started a new conversation Confirmation Before Deletion Through View-components/grids

How Can I link the confirmation box before deletion (for deleterec column in code) to the view-application grids code shown below. Can I change the setattribute('onclick') function.


            $provider = new EloquentDataProvider(User::class);
        //$provider = new DbTableDataProvider($pdoConnection, 'my_table');
         $input = new InputSource($_GET);

          $columns = [
                       'id' => new Column('Edit'),
                       'name' => new Column('name'),
                       'address' => new Column('address'),
                       'contactno'=> new Column('contactno'),
                       'email'=> new Column('email'),
                       'deleterec' => new Column('Delete Record')
                     ];
              // create grid
          $grid = new Grid( $provider, $columns,
          
          [
          
        new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
        new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
        new ColumnSortingControl('id', $input->option('sort')),
        new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
        new CsvExport($input->option('csv'))
          
          ]
          
         
          
          );
             // all components are optional, you can specify only columns
       
       
        
        
        //new TableCaption('My Grid'),
       
           
        
        $columns['id']->setValueFormatter(function ($id, $row) {
              return "<a href='". url('/editrecord')."/{$row->id}'>Edit</a>";
           })
          ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
        
        
        $columns['deleterec']->setValueFormatter(function ($id, $row) {
              return "<a href='". url('/deleterecord')."/{$row->id}'>Delete</a>";
           })
          ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
         
        
         //  but also you can add some styling:
         $customization = new BootstrapStyling();
        $customization->apply($grid);
        
        $items = zone_masters::all(['id', 'zone_name']);
        
            return view('mynewgrid', compact('grid','items'));

27 Nov
11 months ago

anp24 left a reply on Dropdown In Laravel

Please reply as it is urgent

anp24 left a reply on Message Pop Up With Yes /no In Laravel

Again Confirmation is done in Jquery , which is not required, I want confirmation code written in Controller

anp24 left a reply on Message Pop Up With Yes /no In Laravel

Please tell me how to show the delete warning from Controller itself and not the javascript as the javascript can be disabled also

anp24 left a reply on Pagination , Page Size Select Not Displaying In View-components/grids

Now please help how do I do refactoring as I am new to laravel

anp24 started a new conversation Dropdown In Laravel

How do I fill the drop down through controller and the drop down is placed in blade.php. Drop down must be multi select. Also only server side php mvc laravel code is required.

anp24 left a reply on Pagination , Page Size Select Not Displaying In View-components/grids

please answer my question on the basis of above code

24 Nov
11 months ago

anp24 left a reply on Pagination , Page Size Select Not Displaying In View-components/grids

Please answer this question as I am stuck

anp24 started a new conversation Message Pop Up With Yes /no In Laravel

How do I include Message Pop ups in Laravel, so as to implement functionality such as

"If record is deleted, the message from controller must be displayed, as to warn the user,

"do you want to delete the record?"

anp24 started a new conversation Pagination , Page Size Select Not Displaying In View-components/grids

I have included the following code in my controller


$provider = new EloquentDataProvider(User::class);
        //$provider = new DbTableDataProvider($pdoConnection, 'my_table');
         $input = new InputSource($_GET);

          $columns = [
                       'id' => new Column('Edit'),
                       'name' => new Column('name'),
                       'address' => new Column('address'),
                       'contactno'=> new Column('contactno'),
                       'email'=> new Column('email'),
                       'deleterec' => new Column('Delete Record')
                     ];
              // create grid
          $grid = new Grid( $provider, $columns,
          
          [
          
        new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
        new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
        new ColumnSortingControl('id', $input->option('sort')),
        new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
        new CsvExport($input->option('csv'))
          
          ]
          
         
          
          );
             // all components are optional, you can specify only columns
       
       
        
        
        //new TableCaption('My Grid'),
       
           
        
        $columns['id']->setValueFormatter(function ($id, $row) {
              return "<a href='". url('/editrecord')."/{$row->id}'>Edit</a>";
           })
          ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
        
        
        $columns['deleterec']->setValueFormatter(function ($id, $row) {
              return "<a href='". url('/deleterecord')."/{$row->id}'>Delete</a>";
           })
          ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
         
        
         //  but also you can add some styling:
         $customization = new BootstrapStyling();
        $customization->apply($grid);
        
        
        
            return view('mynewgrid', compact('grid'));

But now I have the following problem

pagination , page size select control are not displaying

23 Nov
11 months ago

anp24 left a reply on Include Edit & Delete Button In View-components/grids

I want to know if Edit and Delete button for each row of the view-components/grids is possible or not

anp24 left a reply on Grids Edit Link In Controller Issue

Issue is resolved as I changed the code to below code

            $provider = new EloquentDataProvider(User::class);
        //$provider = new DbTableDataProvider($pdoConnection, 'my_table');
         $input = new InputSource($_GET);

          $columns = [
                       'id' => new Column('id'),
                       'name' => new Column('name'),
                       'address' => new Column('address'),
                       'contactno'=> new Column('contactno'),
                       'email'=> new Column('email')
                     ];
              // create grid
          $grid = new Grid( $provider, $columns,
          
          [
          
        new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
        new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
        new ColumnSortingControl('id', $input->option('sort')),
        new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
        new CsvExport($input->option('csv'))
          
          ]
          
         
          
          );
             // all components are optional, you can specify only columns
       
       
        
        
        //new TableCaption('My Grid'),
       
           
        
        $columns['id']->setValueFormatter(function ($id, $row) {
    return "<a href='". url('/editrecord')."/{$row->id}'>Edit</a>";
         })
        ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
         
    
        
         //  but also you can add some styling:
         $customization = new BootstrapStyling();
        $customization->apply($grid);
        
        
        
            return view('mynewgrid', compact('grid'));

But now I have different problem

pagination , page size select control are not displaying

anp24 left a reply on Grids Edit Link In Controller Issue

On changing it is giving me following error

Type error: Argument 1 passed to ViewComponents\ViewComponents\Component\ManagedList::setDataProvider() must implement interface ViewComponents\ViewComponents\Data\DataProviderInterface or be null, array given, called in C:\xampp\htdocs\CPMS\vendor\view-components\view-components\src\Component\ManagedList.php on line 45

anp24 left a reply on Grids Edit Link In Controller Issue

does any one can answer my issue, do you have any further queries

anp24 started a new conversation Grids Edit Link In Controller Issue

I have created my Grid in the Controller as below

    $provider = new EloquentDataProvider(User::class);
        //$provider = new DbTableDataProvider($pdoConnection, 'my_table');
         $input = new InputSource($_GET);

          $columns = [
                       'id' => new Column('id'),
                       'name' => new Column('name'),
                       'address' => new Column('address'),
                       'contactno'=> new Column('contactno'),
                       'email'=> new Column('email')
                     ];
              // create grid
          $grid = new Grid( $provider,$columns,
             // all components are optional, you can specify only columns
       [
        //new TableCaption('My Grid'),
       
        //new DetailsRow(new SymfonyVarDump()), // when clicking on data rows, details will be shown
        new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
        new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]), // allows to select page size
        new ColumnSortingControl('id', $input->option('sort')),
        new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
        new CsvExport($input->option('csv')), // yep, that's so simple, you have CSV export now
        
        ]
        );
        
        $columns['id']->setValueFormatter(function ($id, $row) {
        return "<a href='editrecord/{$row->id}'>Edit</a>";
         })
        ->getDataCell()
        ->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
        ->setAttribute('style', 'cursor:pointer');
         
    
        
         //  but also you can add some styling:
         $customization = new BootstrapStyling();
        $customization->apply($grid);
        
       $users = DB::select('select * from users where Id = ?',[$id]);
        return view('mynewgridedit',['users'=>$users],compact('grid'));

Now If i am selecting the first row in the grid for Edit, its route is going as

http://localhost/CPMS/public/editrecord/1

but if I am selecting the second row, the link is broken because it is giving me link as

http://localhost/CPMS/public/editrecord/editrecord/2

Also the route I have given in my web.php is

Route::get('/editrecord/{id}','[email protected]');

How Can I correct the route?