Wednesday, 13 July 2016

How to solve Call to undefined method Illuminate\Database\Query\Builder::links()


When building pagination in laravel it is more likely to come across this error call to undefined method. This happen when trying to get other record in the variable.

This problem is cause when a variable that was passed from controller or route is re-generated by foreach statement. To avoid this error, make sure the re-generated variable name by foreach statement is different from the original variable.

And when using the links(), used it with the original variable not the re-generated variable by the foreach statement. For instance,

Assuming $record is our original variable,

@foreach($record as records) // when trying to get other records in the variable.

//display the records

@endforeach

<div class="pagination">{!!$record->links()!!}</div> // display pagination

Take note that this variable “$record”  is different from “$records”. The first is the original variable while the latter is the regenerated variable and we used the original for the pagination

Sunday, 26 June 2016

C++ Program to Calculate Sort Numbers into Ascending Order

This section helps to create a program that will actually help to sort ten numbers into ascending Order regardless of the kind of numbers inputed by users.
Here is the script.


#include <iostream>
using namespace std;
int main()
{
    int num[10],a,b,c;
    cout <<"INPUT NUMBERS" << endl;
    for(int enter=0; enter<10; enter++) {
            cin >> num [enter];
    }
for(a=0; a<10-1; a++)    
{
for(b=a+1; b<10; b++){
 if(num[a]>num[b]){
 c=num[a];
num[a]=num[b];
num[b]=c;
         }                    
 cout <<"HERE IS THE NUMBER IN ASCENDING ORDER   " << endl;

}}
for (a=0; a<10; a++)
    cout<< num[a]<< endl;
   return 0;
}
   
This    int num[10],a,b,c; will create an array capable of storing ten numbers into the num variable, along side with a,b,c which are just normal variable for c++.
This    for(int enter=0; enter<10; enter++) {cin >> num [enter];} will loop ten times to collect ten numbers from keyboard and store it in the num array. 
The second and third for loop work together, that is when the FIRST FOR LOOP loop once, the SECOND FOR LOOP will loop 10 times, also when the FIRST FOR LOOP Loop the second time, the SECOND FOR LOOP will loop another 10 time.  
The SECOND FOR LOOP use if(num[a]>num[b]){c=num[a]; num[a]=num[b]; num[b]=c;} by comparing each element or numbers in the array with the IF STATEMENT and swapping bigger number with  smaller number. Accessing the array element and swapping it is possible because it uses the number of times the for loop provide as a means to access the index of the array.
The FOUTH FOR LOOP access the sorted array index with the number the loop provide and print out their values.
 

Wednesday, 18 May 2016

Whatsapp Desktop App is Now Available



Whatsapp announced that it user will now be able to use whatsapp features in a native desktop app. This native app will be available for modern version of OS of Window 8 and above and mac running OSX 10.9 and above.

Although Whatsapp Web is still available to both OS regardless of Version.

To start using this Application is very simple. First, Visit whatsapp.com/download with your browser, download and open the pertinent app, scan the QR code with the whatsapp Application of Your Mobile Phone.

If you are stuck on how to scan the QR code, go to setting > Whatsapp Web.  This deskop application is the same with the mobile what but the little different I see is that it has a customized notification, better keyboard shortcut etc.
Desktop whatsapp

How to setup Laravel On Windows

This tutorial will guide you on how to install laravel framework on local server. We are going to use xampp server for the sake of this tutorial. But if you follow this tutorial, same step can be applied to other Local Server like Wamp.

Requirement
Xampp download here

Composer Download Here

PHP 5.4 +

Download and install Xampp and ensure it is up and running. Go to Command Line type composer to make sure the composer is up and running. Also type PHP in your Command Line then check if the PHP version is 5.4+.

On the Command Line Interface, Browse to xampp\htdocs Directory. This is where the Laravel Project wwill be stored because we are using xampp. To Browse to a Directory or Folder, type cd\xampp\htdocs\laravel_project_name.

In the Command Line we will now download  Laravel Framework Project  using composer. simply type composer global require "laravel/installer=~1.1" and laravel my_project

Or run composer create-project laravel/laravel –prefer-dist  that command is also used to create a laravel project.

The above guide will help you to install laravel on windows if you have any problem installing or setting it up please put it on the comment box.

Thursday, 7 January 2016

How to install Drupal 8 theme

 Before getting started, ensure that the normal installation process is already settled. All the manipulation of Drupal theme are located by clicking
                Appearance à Theme.
This center is where all Drupal theme manipulation like “set as default”, “delete” are quietly carried out and where all installed themes are displayed.
How to install new Drupal theme
Here comes the main business. Go to https://www.drupal.org/project/project_theme it contain thousands of Drupal beautiful themes that are available for free. Simply select version 8 theme to avoid compatibility conflict, download as .taz.gz file or zip. When  download is successful, carefully follow the method below to install.
Method one
                Open the downloaded theme, unzip or extract into theme folder in Drupal Directory. 
Drupal website > theme.
Method two
                Log into Drupal website as administrator
                Click appearance à Theme à
                Click “install new theme”
                Use file field to browse the extracted theme folder
                Click upload button to install the new theme.
Follow up the upcoming setup wizard that may come up to completely setup the Drupal theme on your website.

Monday, 9 November 2015

Command needs a higher bootstrap level to run in drush

drush icon

This was the error I faced sometimes ago it happened when when I was trying to change my drupal theme with  drush. Everything was running on xampp environment and window 7 machine
Here is the full error report.
Command pm-info needs a higher bootstrap level to run - you will need    [error]

to invoke drush from a more functional Drupal environment to run this
command.
The drush command 'pmi' could not be executed.                           [error]

Drush was not able to start (bootstrap) the Drupal database.             [error]

Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version        :  8.0-dev
 Site URI              :  http://default
 Database driver       :  mysql
 Database username     :  root
 Database name         :  drupal
 PHP executable        :  php.exe
 PHP configuration     :  H:\xampp\php\php.ini
 PHP OS                :  WINNT
 Drush version         :  8.0
 Drush temp            :  C:\Temp
 directory
 Drush configuration   :
 Drush alias files     :
 Drupal root           :  H:/xampp/htdocs/drupal
 Site path             :  sites/default
 Active config path    :  sites/default/files/config_MoeSD5C7JSguok
                          xrBh4-UuwT_r9_jk2Z59QKdN-j9Zx9DIgHBy2dH8n
                          1rGOeKNJpaAAxBi4PzA/active
So this error is occurring because drush is unable to detect and make use of mysql database. So the question is how do i make the connection to my database and to solve command needs  a higher bootstrap level to run. The solution is to declare a mysql path to environmental variables. Eg. c:\xampp\mysql\bin
From the example above, am using xamp so your directory may be different.


Sunday, 8 November 2015

Installing Drush on Windows using Cygwin shell

This is an alternative way to get Drush running on a Windows 7 system using the Cygwin environment. There is existing documentation on installing and running Drush using GnuWin tools and the native Windows shell at: http://drupal.org/node/594744
If you would like develop Drupal projects on Windows 7 using installation profiles, Drush Make and Git, the Cygwin environment provides a powerful toolset which matches configurations that you would might find on Linux or OS X . More information about using Drush Make to develop installation profiles can be found at: http://drupal.org/node/1006620

Requirements

Before you start installing the Cygwin environment you will need to make sure you have an existing installation of PHP on your Windows system which can be called from the command line of a shell program. Installing PHP on Windows 7 is outside the scope of this article but we'll assume you have already installed XAMPP or something. A default installation of XAMPP will mean that a PHP executable is installed at the pathC:\xampp\php\php.exe. This article also assumes that you do not have Windows User Account Control active. There are many articles around the web which explain how to disable it, search for "Disable Windows 7 User Account Control".
To check that PHP is available from your PATH environment variable open the program Command Prompt. Command Prompt is the default shell program for Windows 7, you will find it in your Start menu or you can search for cmd.exe. Test that PHP available by running the command:
php -v
The output should look something like this:
PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)
...
If you get an error that starts with "php is not recognized..." you might need to add the folder containing your PHP executable to the PATH variable. To edit the PATH go to Control Panel > System and Security > System > Advance System Settings > Advanced tab > click the Environment Variables button. In the lower section of the Environment Variables window under System variables select Path, then click Edit.
Assuming that C:\xampp\php\php.exe exists you need to add the following folder to PATH, making sure you separate your new entry with a semicolon.
;C:\xampp\php
Now re-open Command Prompt (you will need to close it first to reload the updated PATH variable) and try typing "php -v". You should see the friendly version number output from PHP. If you still get errors you will need to double check your PHP installation.

Installing Cygwin

Grab the Cygwin Setup program from the homepage of the Cygwin site at:http://www.cygwin.com/
When you run the Cygwin setup.exe program it will select a number of packages to install by default, when you arrive at the Select Packages screen of the setup program you need to install the following additional packages:
  • openssh
  • git
  • rxvt
  • patch
  • patchutils
  • unzip
  • nano
  • vim
  • wget
  • connect-proxy
  • curl
  • rsync
  • bsdtar
  • ncurses
  • mysql
Cygwin Setup will install some additional dependencies and then generate a number of Desktop Shortcuts and Start menu items for the various Cygwin shell programs which have been installed. After you've exited the Cygwin installer you can always install more packages by running the Cygwin setup.exe program again. You won't overwrite your existing installation, you will just be able to add further packages.

Installing Drush using Cygwin

Now that we've got all the required tools we can move onto installing Drush in the Cygwin environment. We will be installing the latest All-versions-5.x-dev version of Drush because it has better support for Windows 7 and also has Drush Make built-in.
To access the Cygwin environment open the Cygwin shell program called rxvt-native. We are going to install Drush in Cygwin at the path /usr/local/src/. In the following step we will download Drush and extract the files from the project archive (at the time of writing the latest version of Drush 5 was a development release, use the latest recommended release of Drush 5 if there has been an update in the meantime). You can find the download link we use below from the Drush project page: http://drupal.org/project/drush
From the command line, type each line in the following text as a separate command:
mkdir -p /usr/local/src
cd /usr/local/src
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
tar -zxf drush-7.x-5.9.tar.gz
Now we should have all the Drush project files at the path /usr/local/src/drush so that the main Drush script is located at /usr/local/src/drush/drush. To complete the installation we need to make some files executable and create a symbolic link so that we can run Drush from anywhere inside Cygwin.
chmod u+x /usr/local/src/drush/drush
chmod u+x /usr/local/src/drush/drush.bat
ln -s /usr/local/src/drush/drush.bat /usr/bin/drush
That completes the installation and setup of Drush in the Cygwin environment, test it out by running drush from the command line:
drush
You should get an output of all the drush commands available.