Browsed by
Category: Laravel

Laravel belongsToMany relationship

Laravel belongsToMany relationship

There are often times when your data has a “belongsToMany” relationship. Laravel handles this relationship really beautifully! I learn best by example, so we’ll do this post as an example I’m currently working on. In our application we have multiple related websites. Each of these sites stands on its own with users being able to register individually on each site. We wanted to update this so that when a user registers on one site their details are automatically pushed to…

Read More Read More

Creating a new laravel site

Creating a new laravel site

Having installed Laravel you’ll now want to create your first Laravel website. Creating the new Laravel site In the command line navigate to the parent directory which contains all your web projects. On my Ubuntu system my projects are all in /var/www/html, so on the command line: cd /var/www/html Decide on a name for your project. We’ll call ours my-cool-website. Now run the new command from the command line like this: laravel new my-cool-website            …

Read More Read More

Node / NPM to manage JS / CSS in Laravel

Node / NPM to manage JS / CSS in Laravel

To manage your js and css files in Laravel you could place your js and css files in the public directory, but using the /resources/assets folder you can add your js and css (sass or less, etc) in there. You then need to compile these with nodejs and NPM. To install nodejs / npm on Ubuntu you can use sudo apt-get install nodejs Once installed in a terminal window navigate to your Laravel project directory and type: node install Once…

Read More Read More

Installing Laravel

Installing Laravel

Laravel is a PHP framework so we need to start with a L(W)AMP server of some sort. We recommend PHP 7 but from PHP 5.6 will do. Laravel is easiest to install with Composer. Once Composer is installed according to their instructions, we can use it to install Laravel. There are different methods of installing Laravel but I prefer installing it as a global package on the system. To do this, on the command line type: composer global require “laravel/installer”…

Read More Read More