# Gettting started with Laravel and lando

lando init

- webroot directory - public
lando start
lando composer create-project --prefer-dist laravel/laravel blah
mv ./blah/* .
mv ./blah/.* .
rmdir ./blah

- set .env variables for lando
DB_HOST=database
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

lando restart

npm init
npm run development

- set up routes
- contents controller handles main content
lando artisan make:controller ContentsController
- add route to web.php 'ContentsController@home'
lando artisan make:controller PersonController
lando artisan make:controller AuditsController
- add CRUD routes

for proxy
lando artisan make:controller ProxyController
lando artisan make:migration create_proxies_table --create=proxies
lando artisan make:model Proxy

- make groups model for drop downs
 lando artisan make:model Group

- set up databse
lando artisan make:migration create_people_table --create=person
lando artisan make:migration create_roles_table --create=roles
lando artisan make:migration create_audits_table --create=audits
lando artisan make:migration create_groups_table --create=groups
lando artisan make:migration create_obroles_table --create=obroles

-create pivot table
php artisan make:migration create_role_user_table
create migration

- add rows
- migrate
lando artisan migrate

- enable authentication
lando artisan make:auth

# helper

- rollback datatbse
lando artisan migrate:refresh
or
lando artisan migrate:fresh

set up roles and seeder
https://medium.com/@ezp127/laravel-5-4-native-user-authentication-role-authorization-3dbae4049c8a

lando artisan migrate:fresh --seed

add this
  public function __construct()
  {
    $this->middleware('auth');
  }
  public function index(Request $request)
  {
    $request->user()->authorizeRoles(['cd_admin', 'admin']);
    return view(‘home’);
  }

obi8
script - https://github.com/merorafael/docker-php
get files from - https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html?
used 12.2.0.1.0 base and sdk unzip
lando composer require yajra/laravel-oci8:"5.7.*"
lando composer yajra/laravel-oci8:"5.7.*" install

submitting json in laravel
https://itsolutionstuff.com/post/laravel-dynamically-add-or-remove-input-fields-using-jqueryexample.html

added telescope - https://github.com/laravel/telescope
https://loader.lndo.site/cd-admin/

use react instead of vue
lando artisan preset react

//packages
composer require spatie/laravel-permission

//unit testing
php artisan make:test UserTest

better way to make migrations and factory
lando artisan make:model Security_Role -m -f

lando artisan make:model Security -m -f

DB dump
DB::listen(function ($sql) {var_dump($sql->sql, $sql->bindings);})

DB::enableQueryLog()
DB::getQueryLog()

make the controllers
lando artisan make:controller SecurityRoleController
ando artisan make:controller SecurityController


## typical naming convention Routes web.php

 * https://laracasts.com/series/laravel-from-scratch-2018/episodes/11
 * Naming convention for resource controller
 * lando artisan make:controller ProjectsController -r -m Project
 * Get /projects (index)
 * Get /projects/create (create)
 * Get /projects/{id} (show)
 * Post /projects (store)
 * Get /projects/{id} (edit)
 * Patch /projects/{id} (update)
 * Delete /projects/{id} (deystroy)
 * THIS DOES ALL OF THAT
 * Route::resource('projects', 'ProjectsController')
 * forms require method field
 * {{ method_field('PATCH') }}
 

 request()->all() //gets all input data

### validation 
https://laracasts.com/series/laravel-from-scratch-2018/episodes/15
@if ( $errors->any() )
    @foreach ($errors->all() as $error)
        <li>{{ $error }} </li>
    @endforeach

$validated = validate( [
    returns array with attributes
])

Project::create( $validated );

adds csrf field
@csrf 


## foreign keys

in migration
$table->unsignedInteger('owner_id');

$table->foreign('owner_id')->references('id')->on('users')->onDelete('cascade');

# laravel helper function for abort

abort_if($project->owner_id !== auth()->id(), 403);

or abort_unless

## policies for authentication

php artisan make:policy ProjectPolicy --model=Policy
https://laracasts.com/series/laravel-from-scratch-2018/episodes/27

then add policy to app/Providers/AuthServiceProvider.php $policies array

authorize 
validate
store
return

gate before overides all other validation policies

## email https://laracasts.com/series/laravel-from-scratch-2018/episodes/30

mailtrap free user account

## PHP

$obj = (object)['name' => "phil", 'length' => 100];


@csrf adds token to blade form

blongsToMany

nova component -  to create custom component


DEV_TEST_INSTANCE=cu-obproxy-02
DEV_TEST_IP=208.118.251.154
TEST_URL=https://test-obieeaccess.it.cornell.edu/


PROD_INSTANCE=cu-obproxy-01


ADD “OAS” to Security Roles = OAS Security Roles
DROP “and Roles” from Authorizers and Roles = Authorizers
Manual tab still says OBIEE at bottom, vs OAS
