merubah string jadi variabel di PHP

20:51 Unknown 0 Comments

$$ mengubah string jadi variabel

  for ($i=1; $i <= 10; $i++) {

    $b='bulan'.$i;

    $$b='bulan ke'.$i;

  }



echo $bulan3; //hasilnya bulan ke3



dokumentasi resmi PHP nya http://php.net/manual/en/language.variables.variable.php

0 comments:

Edit password user login

20:01 Unknown 0 Comments

public function updateProfile($id,Request $request){

        $rules=[
            'old_password'=>'required|old_password_validation',
            'password'=>'required|confirmed',
            'password_confirmation'=>'required'];
       
        $pesan=[
            'old_password_validation'=>'Pasword lama Salah',
            ];

        Validator::extend('old_password_validation', function($field, $value, $parameters)
            {
                return Hash::check($value, Auth::User()->password);
            });

        $validator = Validator::make($request->all(), $rules, $pesan);  
             if ($validator->fails()){
                  return redirect()->back()
                    ->withErrors($validator)
                    ->withInput($request->except('password'));
            }

            $user=User::find($id);
            $user->password=bcrypt($request->input('password'));
            $user->nama=$request->input('nama');
            $user->save();

            return redirect()->back();

    }

0 comments:

Faker di Laravel

18:17 Unknown 0 Comments

faker di laravel berfungsi untuk membuat data dummy jadi jika kita butuh sample data banyak..
tidak perlu menginput satu-satu ke dalam database
CMIWW

contoh penggunaan

$faker = Faker\Factory::create();

    $limit = 10000;

    $users=App\User::all();

    for ($i = 0; $i < $limit; $i++) {
        App\User::create([
        'name'=>$faker->name,
        'email'=>$faker->unique()->email,
        'phone'=>$faker->phoneNumber
        ]);
    }


dari syntax di atas akan menginput data sejumlah 10000 record ke table user..
jadi data di looping sesuai variable limit

0 comments:

loop variable di laravel 5.3

23:03 Unknown 0 Comments

doc laravel blade loop

$loop->iteration /untuk mengambil no looping sekarang

$loop->count /untuk menghitung jumlah looping

0 comments:

Laravel-elixir-error

20:44 Unknown 0 Comments

error saat running gulp

TypeError: Elixir.ready is not a function
    at Object.<anonymous> (/var/www/html/demand/node_modules/laravel-elixir-vue/main.js:3:8)

masuk ke direktori project 

npm install laravel-elixir-vueify

dan jika masih ada error atau ada error seperti ini 

TypeError: Cannot read property 'transformers' of undefined

jalankan perintah 

npm install laravel-elixir-browserify-official --save-dev


rubah file gulpfile.js

awal
require('laravel-elixir-vue');

menjadi
require('laravel-elixir-vueify');

reference:

https://github.com/JeffreyWay/laravel-elixir-browserify

https://github.com/JeffreyWay/laravel-elixir-vueify

https://github.com/JeffreyWay/laravel-elixir-vueify/issues/26

https://github.com/JeffreyWay/Laravel-Elixir-v6-Vue-example/issues/1

https://laracasts.com/discuss/channels/elixir/cannot-find-module-vendorlaravelelixirelixir


0 comments:

cara install gulp di ubuntu

19:05 Unknown 0 Comments

cara install gulp di ubuntu



Masuk ke direktori laravel 
jalankan perintah npm install gulp

0 comments:

Apa Yang Baru di Laravel 5.3 ??

18:52 Unknown 0 Comments

direktori dan file routes berubah

di laravel 5.2 file routes.php ada di app/http/routes.php

sedangkan di laravel 5.3 routes.php berubah menjadi web.php dan direktori menjadi routes/web.php

route logout,, jika di laravel sebelumnya Route::get('logout'),method harus di rubah jadi post

0 comments:

laravel error composer

18:39 Unknown 0 Comments



solusi..

update composser..

composer self-update

0 comments: