Skip to content

Instantly share code, notes, and snippets.

@prasanth22
prasanth22 / webdev_online_resources.md
Last active November 24, 2020 05:31 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@prasanth22
prasanth22 / laravel_clone.txt
Created April 9, 2020 13:33
laravel clone setup
composer install
Copy .env.example file to .env
Open your .env file and change the database conf
php artisan key:generate
php artisan migrate
php artisan serve
@prasanth22
prasanth22 / pdocrash.php
Created April 19, 2020 04:28 — forked from bradtraversy/pdocrash.php
PDO & Prepared Statements Snippets
<?php
$host = 'localhost';
$user = 'root';
$password = '123456';
$dbname = 'pdoposts';
// Set DSN
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// Create a PDO instance

My Laravel Documentation

  • Create Thread model, migration and Resourceful controller

    php artisan make:model Thread -mr

  • Create Reply model, migration and simple controller

    php artisan make:model Reply -mc

check the following links for the useful packages in Laravel:
https://www.cloudways.com/blog/best-laravel-packages/

  • barryvdh/laravel-debugbar : Link
    This is a package to integrate PHP Debug Bar with Laravel
  • Socialite : Link
    Socialite is a very popular package for handling social authentication with OAuth. It works with Facebook, Twitter, Github, Bitbucket, and a few others.
  • LARAVEL-MODULES : Link
    Laravel package which was created to manage your large Laravel app using modules.
  • arrilot/laravel-widgets : Link
    Generate and use widgets

one to one :
user can have profile or address user has one profile:
add this in user model as:

public function profile()
{
 return $this->hasOne(Profile::class);
}

php

Associative Arrays:
index.php

<?php 
$person = [
	'age' => 31,
	'hair' => 'brown,
	'career' => 'web developer'
];
<?php
$host = 'localhost';
$user = 'root';
$password = '123456';
$dbname = 'pdoposts';
// Set DSN
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// Create a PDO instance
<?php 

try {
    $pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}catch( PDOException $e ){
    die("couldn't connect ".$e->getMessage());//gives error message
}

$statement = $pdo->prepare('select * from todos');