Categories
General

Virgin Media Calling and Asking for Password

Advertisements

Receiving a phone call from Virgin Media

Last week sometime, I received a phone call from Virgin Media. The caller said he would like to talk to me regarding my account, which at first seemed fairly legit. I asked him what the problem was and to his response, I was shocked.

The reply was “Firstly Michael, I need to know your password”. After telling him that I’m not giving him my password as he rang me. He should know that he is talking to the correct person.

Personally, I felt like this could have easily been some fraudulent call. After him not giving up on this, despite me asking several times what it was actually regarding and him repeating… “I can’t tell you until you give me your password”. I said to him that you can send me a letter with what this is regarding and I hung up.

The problem continues

This wouldn’t have been a problem if I was the one who rung them up. But the fact he did this when calling ME, I was not going to tell him. I personally feel that this isn’t the best way to handle the call, and he should have asked me other questions like my address or say the 2nd and 5th characters of my password. If I were to have friends/family around, I wouldn’t tell him my password as it could be used on other websites like Facebook and Twitter, so it should be dealt in another way.

The terms even speak about not asking for your password (shown below). Surely this means they are going against their own terms on this.

If anyone has had the same, or similar experiences on this then please share your thoughts and what you did to deal with the situation.

They did in fact send me a letter, and it was to do with being behind on payments. Why they couldn’t even hint at this still baffles me, but I rang them up and had it all sorted.

Protecting your information

Any information sent to us is protected using robust security methods. The methods we use are industry-standard ensuring data is safeguarded whilst being sent over unprotected communications paths such as the internet. When it reaches us, we store it securely and only provide access to it by those authorised. Although we safeguard your personal information once received, Virgin Media cannot guarantee the safety of any personal information you transmit to us using online methods.

We will never ask you for your Virgin Media identification, authentication passwords or PIN numbers directly associated with your Virgin Media account in any unsolicited phone calls or unsolicited emails. In accordance with our Terms and Conditions, you are responsible for keeping your password and PIN secure and we very strongly recommend you do not disclose them to anyone (unless you wish to authorise them to access your account and potentially incur charges on your account).

https://store.virginmedia.com/the-legal-stuff/privacy-policy.html

Categories
Laravel

Nice little Laravel tip (Blade Ternary Operator)

Advertisements

Just today, I was looking at using a ternary operator in Laravel’s Blade templating system and thought to myself… “There must be a better way of doing this”. After a quick Google aanndd… BEHOLD THE OR STATEMENT! Since version 4.1 they managed to sneak in this “or” statement and it’s managed to bypass so many people (I figured this out by the lack of voices shouting about this on Google).

So, instead of doing something like this…

{{ (isset($title)) ? $title : 'default title here' }}

You can try using “or” like so…

{{ $title or 'default title here' }}

And there you have it ladies and gentlemen, your future Blade documents will look even more lovely. Please, thank me later.

Categories
Laravel

Laravel Localhost removing /public/index.php

Advertisements

I have been in the Laravel chats for quite a while now and one question which I see regularly is how to remove the public/index.php directory on Localhost. The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run php artisan serve. That’s it. You’re done. Don’t believe me? Check out https://localhost:8000 and admire your Laravel work.

Another way, but a bit more complicated would be to set up a virtual host (vhost) and point it to the public folder inside your projects main directory. Have a Google around if this is what you prefer and you will find so many tutorials showing you just how to do this.

Something which is a lot newer is Vagrant, now this will set up a Virtual Machine which you can SSH into and run a local environment for your PHP. Check it out and find some tutorials on installing a LAMP environment inside your Vagrantproject.

Laravel’s version 4.2 will be coming packaged with something called Homestead which will have a Vagrant configuration. This will allow you to go straight into Laravel and run a Vagrant box straight away with little to no configuration what so ever.

So, try each of these examples out and find out which one is easiest for you. If you have another way then please let us know in the comments and share your experiences with setting up a Laravel project.

Categories
Laravel

Laravel Dynamic Navigation Package

Advertisements

I have managed to create a dynamic navigation package for Laravel which can be seen in my previous post. If you go to Packagist you will be able to find my package under checkeredmichael/navigation.

I have created a readme with this package which should get you started on implementing it within your own projects. I would like to get as many people as possible to use this package and come back with feedback/bug fixes.

This is my very first public package and I will be using it to expand on other packages such as my very own admin package for Laravel which will be created in the future.

If anyone requires further assistance then please let me know in the comments of this post or contact me.

Categories
Laravel

Laravel Dynamic Menu Tutorial (Best for Admin packages)

Advertisements

Learn more Laravel

Creating a dynamic menu

Thanks to this very Laravel topic over at Laravel.io and Josh Benham. I managed to find out how to make my very own dynamic menu. In this tutorial, I will show you exactly how it’s done. Hopefully, you will now be able to make amazing admin packages for Laravel.

For those that just want the package then you can download it the Laravel dynamic navigation package. Otherwise, continue below.

First off, I am doing this in my very own package. My directory structure will look pretty much like anyone else file structure which will be within the src/Package/Admin. Hopefully, you should be able to follow this along just fine. However, if you have any problems or even any suggestions for improvements then feel free to let me know.

Within my Admin folder, I create a new folder called services and create a file called ‘Menu.php’. This is the code you should type within this file…

services/Menu.php

<?php

namespace PackageAdminServices;

use Illuminate\Support\Facades\HTML;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\URL;

class Menu { 
    protected $items;
    protected $current;
    protected $currentKey;
    
    public function __construct() {
        $this->current = Request::url();
    }

    /** Shortcut method for create a menu with a callback.
     * This will allow you to do things like fire an even on creation.
     * @param callable $callback Callback to use after the menu creation 
     * @return object
     */ 
    public static function create($callback) {
        $menu = new Menu(); $callback($menu);
        $menu->sortItems(); return $menu;
    }
    
    /** Add a menu item to the item stack
     * @param string $key Dot separated hierarchy 
     * @param string $name Text for the anchor 
     * @param string $url URL for the anchor 
     * @param integer $sort Sorting index for the items 
     * @param string $icon URL to use for the icon 
     */
    public function add($key, $name, $url, $sort = 0, $icon = null) { 
        $item = array(
            'key' => $key,
            'name' => $name,
            'url' => $url,
            'sort' => $sort,
            'icon' => $icon,
            'children' => array()
            );
        $children = str_replace('.', '.children.', $key);
        array_set($this->items, $children, $item);
        if ($url == $this->current) {
            $this->currentKey = $key; }
    }
    
    /** Recursive function to loop through items and create a menu 
     * @param array $items List of items that need to be rendered 
     * @param boolean $level Which level you are currently rendering 
     * @return string
     */
    public function render($items = null, $level = 1) { 
        $items = $items ?: $this->items;
        $attr = array( 'class' => 1 === $level ? 'menu level-1' : 'level-' . $level );
        $menu = '<ul' . HTML::attributes($attr) . '>'; foreach($items as $item) {
            $classes = array('menu__item');
            $classes[] = $this->getActive($item);
            $has_children = sizeof($item['children']);
            
            if ($has_children) {
                $classes[] = 'parent';
            }
            $menu .= '<li' . HTML::attributes(array('class' => implode(' ', $classes))) . '>';
            $menu .= $this->createAnchor($item);
            $menu .= ($has_children) ? $this->render($item['children'], ++$level) : '';
            $menu .= '</li>'; }
            $menu .= '</ul>';
        return $menu;
    }
    
    /** Method to render an anchor 
     * @param array $item Item that needs to be turned into a link 
     * @return string 
     */
    private function createAnchor($item) {
        $output = '<a class="menu__item" href="' . $item['url'] . '">';
        $output .= $this->createIcon($item);
        $output .= $item['name'];
        $output .= '</a>';
        return $output;
    }
    
    /** Method to render an icon 
     * @param array $item Item that needs to be turned into a icon
     * @return string
     */
    private function createIcon($item) {
        $output = ''; if($item['icon']) {
            $output .= sprintf('<i class="glyphicon glyphicon-%s"></i>', $item['icon']);
        } return $output;
    }
    
    /** Method to sort through the menu items and put them in order 
     * @return void 
     */
    private function sortItems() { 
        usort($this->items, function($a, $b) {
            if($a['sort'] == $b['sort']) {
                return 0;
            }
            return ($a['sort'] < $b['sort'] ? -1 : 1);
        });
    }
    
    /** Method to find the active links 
     * @param array $item Item that needs to be checked if active 
     * @return string 
     */
    private function getActive($item) {
        $url = trim($item['url'], '/');
        if ($this->current === $url) {
            return 'active current';
        }
        
        if(strpos($this->currentKey, $item['key']) === 0) {
            return 'active';
        }
        
        return '';
    }
}

Get all that?

This code will set you up for all the behind-the-scenes stuff. Hopefully, most of it is pretty self-explanatory (like most of Laravel). The code should be well commented to give you a grasp on what is going on.

Next, we will make our navigation which will be within the views folder. I created an inc folder within my views to keep things tidy called ‘navigation.blade.php’. And my code goes a little like this…

<?php use PackageAdminServicesMenu; ?>

{{ Menu::create(function($menu) {
    Event::fire('admin.menu.build', $menu); })
    ->render(); }}

This will display your navigation, but the only trouble is that we haven’t actually built it. Here we have the code to build our dynamic navigation menu. Inside your AdminServiceProvider.php you need to add this line into your public function boot()

include __DIR__ . '/../../events.php';

This will tell your package where to find the events page which will build up your navigation. Your events.php needs to be in the same place as your routes and filters. This should be in the src folder…

<?php
Event::listen('admin.menu.build', function($menu){
    $menu->add('index', 'Index', URL::route('Admin::index.index'), 1, 'dashboard');
    $menu->add('users', 'Users', URL::route('Admin::users.index'), 100, 'users'); });

Here we use the event listen method used in Laravel to build our menu. The first part of our add method gives a key which enables a check to see if it’s the current page or not. The second part adds text to your link, URL::route will be the route name which you use in your routes.php. We then have these numbers which says where they should be displayed on the nav and users or dashboard is a font awesome icon.

Phew, that was a lot to take in…

Hopefully, this is enough to get anyone started on a dynamic nav, if you need to use it on more packages then just add the code to the service provider, add another event .php and then create similar code to that above which will build up your navigation even more.

I would also like to thank Josh Benham for his help and support. Check out the discussion at laravel.io.

If you would like to pull in the package I created then take a look at my next post. Laravel dynamic navigation package.

Feel free to add your own feedback in the comments below

Enjoy reading this blog? Please consider subscribing using the form below.

Categories
Composer

Composer Private Repository Problems

Advertisements

Cross development can be a pain…

Recently I have been finding out the slight differences between Windows and Linux for use with Laravel and Composer. One difference is Windows isn’t picky about the way you set out Composer’s packages which can be a major problem. Here’s the issue I had and what I had to do to get it going…

{
    "name"
}: 
"laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"repositories": [
    {
        "type": "vcs",
        "url": "git@bitbucket.org:mbrookspulse8/admin.git",
        "url": "git@bitbucket.org:pulse8/haulfryn-admin-sliders.git",
        "url": "git@bitbucket.org:pulse8/haulfryn-admin-parks.git",
        "branches-path": false,
        "tags-path": false
    }
],
"require": {
    "laravel/framework": "4.1.*",
    "cartalyst/sentry": "2.1.*",
    "imagine/Imagine": "0.5.0",
    "edvinaskrucas/notification": "2.*",
    "way/generators": "dev-master",
    "pulse8/admin": "dev-master",
    "pulse8/sliders": "dev-master",
    "pulse8/parks": "dev-master",
    "geedmo/yamm3": "dev-master"
},
"autoload": {
    "classmap":
    [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd"
}:
[ "php artisan clear-compiled", "php artisan optimize" ],
"post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ],
"post-create-project-cmd": [ key:generate" ] },
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "stable"
}

As you can see, I placed all of my private VPS URLs into one JSON object. On Windows, everything was fine and dandy, nothing was overwritten and everything could be found easily. However, when I placed it all on the server, this is where I ran into problems. Linux is more strict on standards (which is definitely not a bad thing) and caused a lot of aches and pains for me as I wasn’t coding to these standards. It took me and my team a whole day to suss out what was wrong, but this was our finished code for the private VPS URLs…

"repositories": 
[
    { 
        "type": "vcs",
        "url": "git@bitbucket.org:mbrookspulse8/admin.git",
        "branches-path": false,
        "tags-path": false
    },
    {
        "type": "vcs",
        "url": "git@bitbucket.org:pulse8/haulfryn-admin-sliders.git",
        "branches-path": false,
        "tags-path": false
    },
    {
        "type": "vcs",
        "url": "git@bitbucket.org:pulse8/haulfryn-admin-parks.git",
        "branches-path": false, "tags-path": false
    }
],

They have been separated into their own object and now runs perfectly fine on Windows and Linux. Had similar issues? If so then please feel free to share and let me know how you overcame them.

Categories
General Laravel

Social Networking Website Based in Laravel

Advertisements

Laravel social networking website.

I’ve been wanting to make a social networking website for a long time, one which will rival the big guys. I also thought about maybe doing it following the footsteps of Mark Zuckerberg by recording my steps live on my Blog and get feedback to what others think. That way, I can create something which everyone wants and unleash something which almost everyone will love.

I will also release any tutorial worthy stuff as I go through my development to help anyone else who are thinking of making their own social networking sites using Laravel.

I’m starting out with the basics, such as: registration, messaging, pages etc.

What are your likes and dislikes about Facebook, Google+ and Twitter? Let me know in the comments so I can get some awesome feedback.

Categories
Laravel

First Laravel Tutorial – Controllers and Routes

Advertisements

Commence quick and helpful tutorial…

Previously on a Laravel project, I had to have a slug within my routes which would point to two different tables within my database. I needed a controller which would do the thinking for me. And by this I mean, in my routes I would have…

Route::get('{slug}', 'URLController@index');

And in my Controller, I would have the following to do the thinking for me…

public function index($slug)
{
    if(Page::where('slug', $slug)) {
        //Show page property
    }
    else if(Blog::where('slug', $slug)) {
        //Show Blog property
    }
}

So here we have our logic saying if there is anything in the page table where the slug matches. We show the page with that slug otherwise, show a blog post with the matching slug.

This might not be the best example as a lot of people would have a blog post going to ‘blog/{slug}’ and you might even have the page go to ‘page/{slug}’, but the page structure of a site is always changing and it depends on how you feel people should view your site.

I have found one problem with this mind, if nothing gets found then it will just show a blank page, I haven’t found the good logic which will display errors. Or if you are in production a 404 page.

Categories
General

Brand New Website, Brand New Start

Advertisements

Here I go again, on my quest for a new website…

Of becoming a Web Master. It’s been a while since I properly posted on my Blog. And so I wondered the best way to go about this. As I went back to my old site and old Blog. I looked at it and I couldn’t help but think that the way of making templates on Blogger was a bit too tedious and slap-dashed and was in need of a new website.

Now I’m using Laravel at work and starting to feel like it is such a great tool to use. I felt like I should start my new site using a platform which embraces Laravel and so here I am, using WardrobeCMS.

From what I have seen so far, it bolts on some pretty nifty packages and creates something that is simple and elegant. Rather than HTML, it uses a markdown language which looks amazing and it’s so simple to use.

In the future, I hope to create my own theme for it and maybe even make some packages to enhance what is already becoming a lovely piece of kit. I also plan on doing a lot of tutorials focusing mainly on Laravel itself. And possibly some packages which I find useful through my journey.

#WatchThisSpace