Skip to content

nandalifiya/webhaji

Repository files navigation

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:

Laravel is accessible, yet powerful, providing tools needed for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework, making it a breeze to get started learning the framework.

If you're not in the mood to read, Laracasts contains over 1100 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.

Getting Started


npm install

Create Environtment file

copy file .env.example, paste and rename it to .env

Setting

Database setting

use phpmyadmin to create the database name webhaji. After creating the database, we need to open the .env file inside Laravel project and add the database credentials like bellow with your setting.


DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=webhaji
DB_USERNAME=root
DB_PASSWORD=

if your phpmyadmin have password "toor".

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=webhaji
DB_USERNAME=root
DB_PASSWORD=toor

Setting encryption by typing on project terminal/cmd


php artisan key:generate

make table from migration folder


php artisan migrate

insert dummy data from factory and seeder

php artisan db:seed

setting email on .env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=yourGmailEmail
MAIL_PASSWORD=yourAppPasswordGeneratedFromGmail
MAIL_ENCRYPTION=tls

clear cache after edit env

php artisan config:cache

when stuck or application not update

composer dump-autoload

##Running Laravel


php artisan serve

updating the database(when needed)

php artisan migrate

creating symlink

php artisan storage:link

Walkthrough Laravel Step 1 make model/entity and migrations

  1. create model with migration
php artisan make:model Yourmodelname --migration
  1. check folder database/migration/your_model_name and open it

  2. edit the migration file with column that will be on your model tabel check this link. example on file with same migrations folder

  3. update the migration table on phpmyadmin

php artisan migrate
  1. check folder app/YourModelname and open it

  2. open file and edit the $fillable options (with your edited step number 3, column name can fill in the form), check Category.php for example

Walkthrough Relational table many to many

( optional ) if the model/migration has one to one / one to many / many to many on the migrations file.

check eloquent relation table on this link.

example many to many 2 tabel

  1. make new migration file for relating 2 tabel ex: category and post
php artisan make:migration create_category_post_table --create=category_post
  1. edit the migrations file ex: on folder database/migrations/file_category_post_tabel

  2. edit the app/Post.php see the file

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

//add this import use
use App\Category;

class Post extends Model
{
    //add this method
    public function categories()
    {
        return $this->belongsToMany(Category::class);
    }
}
  1. edit the app/Category.php see the file
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

//add this import use
use App\Post;

class Category extends Model
{
    //add this method
    public function posts()
    {
        return $this->belongsToMany(Post::class);
    }
}

5.done

Walkthrough Relational table one to many

( optional ) if the model/migration has one to one / one to many / many to many on the migrations file.

check eloquent relation table on this link.

example one to many 2 tabel ex: user and post

  1. add the user id to database/migration/create_posts_tabel (see the file)

  2. edit app/User.php see the file

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    //add this method
    public function posts()
    {
        return $this->hasMany('App\Post');
    }
}
  1. edit app/Post.php see the file
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //add this method
    public function users()
    {
        return $this->belongsTo('App\User');
    }
}

Walkthrough Laravel step 2 make controller

create controller

php artisan make:controller NameController --resource

check all url from routes/web.php

php artisan route:list

edit the controller, example on folder app/Http/Controller/PostController.php

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

License

The Laravel framework is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •