Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

anp24

Experience

1,520

0 Best Reply Awards

  • Member Since 3 Weeks Ago
  • 0 Lessons Completed
  • 0 Favorites

11th December, 2017

anp24 started a new conversation Model Relationships • 3 days ago

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"?

9th December, 2017

anp24 left a reply on Disable Blade View Button From Controller • 5 days ago

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

disabled="disabled"

from controller

7th December, 2017

anp24 left a reply on Disable Blade View Button From Controller • 1 week ago

@tykus from controller how do I send this value

anp24 left a reply on Eloquent Query In Laravel 5.5 • 1 week ago

any body has the solution for this error

6th December, 2017

anp24 left a reply on Eloquent Query In Laravel 5.5 • 1 week ago

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

anp24 left a reply on Eloquent Query In Laravel 5.5 • 1 week ago

I have again updated the query , still the same error

anp24 left a reply on Eloquent Query In Laravel 5.5 • 1 week ago

I have updated the query

anp24 left a reply on Eloquent Query In Laravel 5.5 • 1 week ago

I have added the table name, but the same error

anp24 started a new conversation Eloquent Query In Laravel 5.5 • 1 week ago

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

5th December, 2017

anp24 started a new conversation Disable Blade View Button From Controller • 1 week ago

How do I disable Blade View Button from Controller

anp24 started a new conversation Grid Display On Drop Down Selection • 1 week ago

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

1st December, 2017

anp24 left a reply on Laravel 5.5 Inbuilt Login For Different Roles • 1 week ago

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 • 1 week ago

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

anp24 left a reply on Multi Auth In Laravel 5.5 • 1 week ago

@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 • 1 week ago

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 • 1 week ago

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 • 1 week ago

I am new to laravel , please help me

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

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 • 1 week ago

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'));
    }

30th November, 2017

anp24 left a reply on Return To SetValueCalculator In View-components/grids • 2 weeks ago

is there no body to answer my question?

anp24 left a reply on Return To SetValueCalculator In View-components/grids • 2 weeks ago

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 • 2 weeks ago

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) • 2 weeks ago

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

29th November, 2017

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

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) • 2 weeks ago

@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) • 2 weeks ago

@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) • 2 weeks ago

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) • 2 weeks ago

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) • 2 weeks ago

@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

28th November, 2017

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

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

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

please some one answer this

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

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 • 2 weeks ago

KodeCept , How I Do the refactoring?

anp24 started a new conversation Confirmation Before Deletion Through View-components/grids • 2 weeks ago

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'));

27th November, 2017

anp24 left a reply on Dropdown In Laravel • 2 weeks ago

Please reply as it is urgent

anp24 left a reply on Message Pop Up With Yes /no In Laravel • 2 weeks ago

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 • 2 weeks ago

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 • 2 weeks ago

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

anp24 started a new conversation Dropdown In Laravel • 2 weeks ago

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 • 2 weeks ago

please answer my question on the basis of above code

24th November, 2017

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

Please answer this question as I am stuck

anp24 started a new conversation Message Pop Up With Yes /no In Laravel • 2 weeks ago

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 • 2 weeks ago

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

23rd November, 2017

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

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 • 3 weeks ago

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 • 3 weeks ago

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 • 3 weeks ago

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

anp24 started a new conversation Grids Edit Link In Controller Issue • 3 weeks ago

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?

22nd November, 2017

anp24 started a new conversation Include Edit & Delete Button In View-components/grids • 3 weeks ago

I have installed the component - view-components/grids

Now , how do I include edit and delete button in Grid so as to edit and delete records in database

anp24 left a reply on ViewComponents Error In Laravel 5.5 • 3 weeks ago

I have solved the error by installing

composer require view-components/grids

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.