Skip to content

Instantly share code, notes, and snippets.

View imam932's full-sized avatar
🏠
Working from home

imam nawawi imam932

🏠
Working from home
View GitHub Profile
@imam932
imam932 / form.blade.php
Created August 31, 2023 05:29
javascript untuk form otomatis terisi ketika halaman lihat, tambah, edit
<div class="col-sm-6 mb-3">
<label class="form-label" for="npwp">NPWP</label>
<div class="input-group">
<span class="input-group-text"><i class="ti ti-id"></i></span>
<input type="text" name="npwp" id="npwp" class="form-control" placeholder="NPWP"
value="{{$karyawan_detail->npwp }}" required />
</div>
</div>
<div class="col-sm-6 mb-3">
<label class="form-label" for="npwp_file">Foto NPWP</label>
@imam932
imam932 / palindrome.py
Created August 9, 2023 07:48
Python check string is palindrome or not
input = 'akas'
temp = ''
for i in input:
temp = i + temp
if input == temp:
print('yes')
else:
print('no')
@imam932
imam932 / laravel-validate-with-custom-message.php
Created October 5, 2022 11:20
validate form laravel with custom message
<?php
public function check(Request $request){
$input = $request->all();
$this->validate($request, [
'email' => 'required',
'password' => 'required',
],[
'email.required' => 'Email is required',
'password.required' => 'Password is required',
@imam932
imam932 / change-by-input-with-delay.js
Created September 19, 2022 14:26
Auto Change by Input text with Delay
function delayInput(callback, ms) {
var timer = 0;
return function() {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, ms || 0);
};
}
@imam932
imam932 / intro.txt
Created November 17, 2020 17:59
Limit one session per user in Laravel 5
- nambah field sessionid di table user
$ php artisan make:migration add_session_id_to_users_table --table=users
- lakukan migration
$ php artisan migrate
- method sendLoginResponse() ini akan mereplace method yang ada di trait “AuthenticatesUsers”
- tambahkan library berikut
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
@imam932
imam932 / Remove-all-html-tags-from-php-string.php
Last active November 17, 2020 16:35
javascript remove tag html from string, Remove all html tags from php string
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text); //output Test paragraph. Other text
<?php echo substr(strip_tags($row_get_Business['business_description']),0,110) . "..."; ?>
@imam932
imam932 / get-data-muntiple-category_id.php
Created November 14, 2020 08:37
Get data multiple category id with whereIn
<?php
public function index($slug)
{
$parent = Category::where('slug', $slug)->first();
$child = Category::where('parent_id',$parent->id)->get();
$category_id = $parent->id;
$child_array_id = [];
foreach ($child as $key => $value) {
$child_array_id[$key] = $value->id;
}
@imam932
imam932 / cut-string-with-length.js
Last active November 10, 2020 17:00
cut string with spesified length
text = 'this is text'
text.substring(0, 7) + '...'
// output
// this is...
@imam932
imam932 / Controller-use.php
Last active October 21, 2020 07:22
Trait File Upload with resize Laravel Intervention (create, update, delete)
<?php
use App\Traits\Upload;
// in Class
use Upload;
$template = new Template;
$template->name = $request->name;
// is create
@imam932
imam932 / eror-user-mysql-8.php
Created October 14, 2020 08:43
user eror ketika login di mysql 8
//masuk mysql cli
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.policy=LOW;