Laravel ErrorException in Filesystem.php line 111:

10:26 PTG 0 Comments A+ a-

ErrorException in Filesystem.php line 111:
sudo composer update
sudo chmod -R gu+w storage
sudo chmod -R guo+w storage
sudo php artisan cache:clear

Laravel: Delete model & Delete Migration

6:16 PTG 0 Comments A+ a-

Deleting a model: just delete the model under App/ or whatever other folder.

Deleting a migration: if you have migrated it (meaning the database has suffered changes) you have two choices:

The "project starting"/ugly way is to migrate:rollback until the migration is undone (if it was the last migration you did, one rollback is enough, if not, you're gonna have to rollback a couple of times) then delete the migration file (the one inside the database/migrations folder. Important thing here: the migration's class will still be autoloader by composer. So you have to remove the migration class loading from vendor/composer/autoload_classmap.php. Maybe composer dumpautoload will work, it didn't for me though. If you have no important data in the DB and you can wipe it, delete the migration file, composer dumpautoload then run php artisan migrate:refresh. This will rollback every migration then migrate everything back in.

The "this is in production and I messed up" way: create another migration where the up method is dropping the first migration's table, down is creating it (basically the up method from the first migration). Leave the two migration files in there, don't remove them.

If you haven't migrated it, just delete the migration file, composer dumpautoload and if you have some class/file not found error, check if vendor/composer/autoload_classmap.php has the class of the file you just removed and delete the row there.

Projek Laravel - Daftar Tugas

11:35 PTG 0 Comments A+ a-

1 . MENCIPTA PROJEK

1- Buat projek diberi nama daftar tugas.
 sudo composer create-project laravel/laravel daftar_tugas "5.2.*" --prefer-dist

2 . SETTING UNTUK DATABASE

2- Masuk dalam SQl dan database.
mysql -u root -p
create database daftar_tugas;



Table seperti ini, perlu dicipta didalam mysql
Dibawah ini, keadaan folder sebelum php artisan migration dilaksanakan


Pastikan berada di folder laravel yang sedang ingin dibuat migration itu untuk laksanakan tugas php artisan
 php artisan make:migration tugas
Created Migration: 2016_12_29_073910_tugas




Dibawah ini, keadaan folder selepas php artisan migration dilaksanakan. Kelihatan 2016_12_29_073910_tugas.php telah dicipta.




Ubah 2016_12_29_073910_tugas.php tersebut seperti dibawah, iaitu memasukkan table id,judul,deskripsi dan timestamp
 


    public function up()
    {
             Schema::create('tugas', function (Blueprint $table) {
            $table->increments('id');
            $table->string('judul');
            $table->string('deskripsi');
            $table->timestamps();
        });
    }


Dan:


    public function down()
    {
               Schema::drop('tugas');
    }


Sebelum melaksanakan php artisan migrate, pastikan hanya tugas.php sahaja yang ada didalam folder migrations.
Run di terminal:
  php artisan migrate


3 . SETTING UNTUK MODEL


 php artisan make:model Tugas
Model created successfully.

 

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tugas extends Model
{
 protected $table = 'tugas';
 protected $fillable = ['judul','deskripsi'];
}

4. SETTING UNTUK CONTROLLER

Check route yang ada. Didapati hanya satu sahaja route.
php artisan route:list

laksanakan command:
 php artisan make:controller TugasController


di file daftar_tugas\app\http\routes.php
 

Route::get('/', function () {
    return view('welcome');
});

Route::resource('tugas','TugasController');


Route yang banyak selepas selepas penambahan command Route::resource('tugas','TugasController'); di route.php

Laravel : if endif for endfor

10:02 PTG 0 Comments A+ a-

          @for ($i=0; $i<5; $i++)
                 @if ($i % 2 === 0)
                      
  • Iteration {{ $i+1 }}
  • @endif @endfor





    Asas @yield dan @section didalam Laravel (Bahasa Melayu/Malaysia)

    10:42 PTG 0 Comments A+ a-

    1. Kita buat panggilan 3 @yield in Main Layout
    -- HTML headers ... 
    
    @yield('css')
    
    -- HTML Body 
    
    @yield('content')
    
    -- HTML footer
    
    @yield('javascript')
    


    2. Kemudian kita pecahkan isi javascript,content dan css mengikut section untuk dipanggil. Setiap @section perlu berakhir dengan @stop.
    // for example in main.blade.php
    @section('css')
        
    @stop
    @section('content')
        // content of main
    @stop
    @section('javascript')
        

    Aturcara Ringkas Penggunaan Laravel (Bahasa Melayu)

    7:34 PG 0 Comments A+ a-

    1. http->routes.php
    Route::get('/', function () {
        return view('home');
    });
    
    

    2.public->resources->views->home.blade.php
    @extends('layouts.master')
    @section('content')
    

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.

    @endsection

    3. public->resources->views->layouts->master.blade.php
    
    
        
            
            @yield('title')
     	
            
            @yield('styles')
            
            
            @include('includes.header')
            
    @yield('content')

    4. public->resources->views->includes->header.blade.php

    5. public->src->css->main.css
    body {
        font-family: "Roboto", sans-serif;
        font-size: 16px;
    }
    
    h1 {
        font-size: 48px;
        margin: 8px 0;
    }
    
    .main {
        padding: 0 32px;
    }
    
    .centered {
        text-align: center;
        vertical-align: middle;
    }
    
    header {
        position: relative;
        padding: 16px 32px
    }
    
    footer {
        position: absolute;
        padding: 16px 0;
        bottom: 0;
        left: 50%;
        -webkit-transform: translate(-50%, 0);
        -moz-transform: translate(-50%, 0);
        -ms-transform: translate(-50%, 0);
        -o-transform: translate(-50%, 0);
        transform: translate(-50%, 0);
    }
    
    nav ul {
        padding: 0;
        margin: 0;
        list-style: none;
        text-align: center;
    }
    
    nav li {
        display: inline-block;
        padding: 0 16px;
    }
    
    header nav li:first-of-type {
        padding-left: 0;
    }
    
    header nav li:last-of-type {
        padding-right: 0;
    }
    
    nav a {
        color: darkgrey;
        text-decoration: none;
    }
    
    header nav a {
        font-size: 26px;
        font-weight: bold;
    }
    
    footer nav a {
        font-size: 12px;
    }
    
    header nav a:hover {
        color: salmon;
    }
    
    

    Mencipta project Laravel kepada edisi Laravel 5.2 atau ke bawah.

    2:12 PG 0 Comments A+ a-

    Jika anda mengikut tutorial didalam internet, anda akan mendapati laravel yang digunakan adalah outdated.

    Ketika ini, pc saya mempunyai sehingga laravel 5.3, dan saya sedang mengikut class di udemy yang mengajar laravel 5.2, untuk project tersebut, saya bina satu project diatas laravel 5.2 seperti didalam udemy.

    composer create-project laravel/laravel myblog "5.2.*" --prefer-dist
    
    sudo chmod -R 777 
    
    

    Laravel: This is my world

    10:35 PTG 0 Comments A+ a-

    1. Selesai install laravel. Mulakan dengan command create project.

    2. Masuk kedalam folder www

    3. composer create-project --prefer-dist laravel/laravel laravel-intro
    dimana laravel-intro adalah folder project
    4. chmod -R 777 laravel-intro/

    5. Buka sublime-text

    6. Menu-> Project->add folder to project

    7. copy server.php ke index.php (sepatutnya dia akan access directly ke paparan dalam folder public di localhost)

    8. laravel-intro->resources->views->welcome.blade.php
    paste:
    
    
    
        
            
            
            
    
            Laravel
    
            
            
    
            
            
        
        
          

    My very first laravel application!

    Hey! It my very first Laravel application.