Tuesday, 20 December 2022

Successfully create AWS Account with gitlab integration


1. create aws ec2 account && with generated pair keys


2. create gitlab repository and push your local files

git remote add origin https://gitlab.com/syafiqzahir94/dtu-laravel.git

git branch -M main

git push -uf origin main 

git pull origin main --allow-unrelated-histories && git push (for existing)


3. putty access

-copy bengkel.pem && generate with puttygen

-connect *host with auth key pairs

-then login as ubuntu


3. setup our bengkel instance in AWS


-install composer

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04


-install php

sudo apt install php


-install apache2

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-20-04

sudo apt install apache2


-install mysql

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04

sudo apt install mysql-server


4. cloning our application from gitlab/github

sudo git clone https://gitlab.com/syafiqzahir94/bengkel.git

Sunday, 11 December 2022

Spatie Laravel Permission & Check Role




$role = Role::findById(3, null); //use spatie\permissions\model\role to get role model;

$role->hasPermissionTo('Complaint Review'); //check role has the valid permission?


auth()->user()->hasPermissionTo('Complaint List'); //check under model user has permission ?

auth()->user()->permissions->pluck('name'); //getting all permissions plucn 'name' under model user

auth()->user()->getAllPermissions()->pluck('name'); //get all permissions name under (role) 


auth()->user()->roles->pluck('name'); //get model user role name

auth()->user()->roles->first()->name; //get role name under user

auth()->user()->roles->first()->name; //get role id under user


auth()->user()->can('Complaint Review'); //check under model_has_permission  

auth()->user()->getPermissionsViaRoles(); //get all permissions collection under role

foreach (auth()->user()->getPermissionsViaRoles() as $permission) {

  echo $permission->name . ' | ';

Saturday, 10 December 2022

Request Laravel Compare Route

Example of getting route name and path in Laravel 8




//get all uri except domain host
request()->getRequestUri();

//raw path info after domain and protocal in uri
request()->getPathInfo();

//trim the slash "/" inside uri
request()->path();

//check route name w/o group
request()->is('licenses');

//get and check route name
request()->route()->named('licenses.index')
  
//get first segment of path url
request()->segments()[0]



Example of Use :







Monday, 5 December 2022

docker commands cli

 





docker commands (vital) :

docker-compose exec php bash -c 'ls'

list of commands :
-pwd
-docker images
-docker ps
-docker container ls
-docker stats
-docker exec -it php bash
-sudo docker-compose down
-sudo docker-compose ps
-docker-compose exec app ls -l
-docker-compose up -d --build
-docker network create axel-cloud-app-shared