Skip to content

Instantly share code, notes, and snippets.

View andri-sudarmawijaya's full-sized avatar

Andri Sudarmawijaya andri-sudarmawijaya

View GitHub Profile
@andri-sudarmawijaya
andri-sudarmawijaya / create_something_down_table.php
Created December 9, 2017 07:11
Drop foreign key when php artisan down
public function down()
{
Schema::table('todolists', function(Blueprint $table)
{
$table->dropForeign('todolists_category_id_foreign');
$table->dropColumn('category_id');
});
}
public function up()
{
Schema::table('todolists', function(Blueprint $table)
{
$table->integer('category_id')->unsigned()->after('id');
$table->foreign('category_id')->references('id')->on('categories');
});
}
@andri-sudarmawijaya
andri-sudarmawijaya / 1README.md
Created January 3, 2018 11:50 — forked from joseluisq/1README.md
How add a custom field to Laravel 5.4 default login. LoginController.php

How add a custom field to Laravel 5.4 default login controller.

In this php example (app/Http/Controllers/Auth/LoginController.php) my model is called Client and the custom field for login validation is status. (Client->status)

Add in your resources/lang/en/auth.php file :

    'failed_status' => 'Your account is inactive yet. Please confirm your e-mail address.',
@andri-sudarmawijaya
andri-sudarmawijaya / AdminUserSeeder
Created January 7, 2018 14:03
How to reset laravel admin password using seeder
- edit file .\database\seeds\DatabaseSeeder.php
- add $this->call(AdminUserSeeder::class);
```
public function run()
{
$this->call(AdminUserSeeder::class);
//$this->call(UsersTableSeeder::class);
}
```
edit file .\database\seeds\AdminUserSeeder.php
CREATE TABLE ref.negara
(
negara_id character(2) NOT NULL,
nama character varying(45) NOT NULL,
luar_negeri numeric(1,0) NOT NULL,
create_date timestamp(0) without time zone NOT NULL,
last_update timestamp(0) without time zone NOT NULL,
expired_date timestamp(0) without time zone,
last_sync timestamp(0) without time zone NOT NULL,
CONSTRAINT negara_pkey PRIMARY KEY (negara_id)
<?php
$sekolah = New stdClass Object
(
[nama] => SMP N 4 CIBINONG
[sekolah_id] => E0E61E14-2CF5-E011-80BF-795521474989
[npsn] => 20254243
[jumlah_kirim] => 5
[ptk] => 49
[pegawai] => 6
@andri-sudarmawijaya
andri-sudarmawijaya / php artisan tinker - create user
Created March 8, 2018 03:25
php artisan tinker - create user
~~~
>>> $user = New App\User;
=> App\User {#812}
>>> $user->name = 'admin';
=> "admin"
>>> $user->email='admin@example.com';
=> "admin@dev.bantenprov.go.id"
>>> $user->password = Hash::make('admin');
=> "$1"
>>> $user->save();
~~~
$table->unique(['product_id', 'company_id', 'price', 'delivery_hours'],
'prices_history_index_unique');
~~~
~~~
---------------------------------------------------------------------------------------------------------------------------------+
| users | CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`role_id` int(10) unsigned DEFAULT NULL,
`remember_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,