Skip to content

Instantly share code, notes, and snippets.

View EmmanuelObua's full-sized avatar
🏠
Working from home

Emmanuel Obua EmmanuelObua

🏠
Working from home
View GitHub Profile
@EmmanuelObua
EmmanuelObua / composer.txt
Last active May 12, 2021 13:48
Composer installation
composer create-project --prefer-dist laravel/laravel:^7.0 laravel-eloquent
@EmmanuelObua
EmmanuelObua / composer-dependencies.txt
Last active May 27, 2021 10:51
Project dependencies
composer require laravel/ui:^2.4
composer require laravel/telescope
@EmmanuelObua
EmmanuelObua / configure-dependencies.txt
Last active May 27, 2021 10:53
Ready the dependencies for use with laravel
//Run this command in the root directory of the project installed using composer
//This command adds ui scaffoldings for the application
php artisan ui bootstrap
//This commands sets up the ui to use bootstrap for authentication
php artisan ui bootstrap --auth
//This commands install node dependencies and compiles frontend assets for laravel default auth functionalities
npm install && npm run dev
@EmmanuelObua
EmmanuelObua / AppServiceProvider.php
Last active May 13, 2021 07:05
App Service Provider
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
//Add the schema facade
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
@EmmanuelObua
EmmanuelObua / artisan.php
Created May 13, 2021 07:23
Models and Migration Artisan command
//These commands generates models and their respective migration files
php artisan make:model Post -m
php artisan make:model Profile -m
@EmmanuelObua
EmmanuelObua / posts-schema.php
Last active May 13, 2021 08:38
Posts migration
<?php
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
//It can be done like this as well in a more simplified way
//$table->foreignId('user_id')->constrained();
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProfilesTable extends Migration
{
/**
* Run the migrations.
@EmmanuelObua
EmmanuelObua / user-profile-relationship.php
Created May 13, 2021 09:49
User model with profile relationship
<?php
/**
* User
*
* @author Obua Emmanuel <eobua6882@gmail.com>
* @copyright 2021 Obua Emmanuel
* @link http://emmanuelobua.me
* @version 1.0.0
*
<?php
/**
* ProfileController
*
* @author Obua Emmanuel <eobua6882@gmail.com>
* @copyright 2021 Obua Emmanuel
* @link http://www.emmanuelobua.me
* @version 1.0.0
*