Postingan

Menampilkan postingan dari 2020

Membuat fungsi global atau ServiceProvider AppServiceProvider Laravel

- contoh untuk convert translate : > buatkan service providernya ->  php artisan make:provider TranslateServiceProvider     Isinya : <?php namespace App\Providers; use App\Library\Services\Translate; use Illuminate\Support\ServiceProvider; class TranslateServiceProvider extends ServiceProvider {     /**      * Register services.      *      * @return void      */     public function register()     {         $this->app->bind('App\Library\Services\Translate', function ($app) {           return new Translate("");         });     }     /**      * Bootstrap services.      *      * @return void      */     public function boot()     {         //     } } > Kalau belum ada folder...

Validasi Laravel (Laravel Validation)

 $this->validate($request, [ //validasi untuk cek form input string max 255 karakter             'nama_kategori' => ['required', 'string', 'max:255'], //validasi untuk cek form input number minimal 1 karakter             'urutan' => ['required', 'numeric', 'min:1'],         ]);

laravel multi languange multi bahasa

- setting library untuk pemanggilan route : https://laraveldaily.com/multi-language-routes-and-locales-with-auth/ - redirect setelah proses request : return redirect(app()->getLocale() . '/home'); - action redirect dengan locale menggunakan redirect controller : return Redirect::action('FaqController@index', app()->getLocale())->with('flash-success','Data Berhasil Diubah.'); - link url tambah locale bahasa : <a href="{{URL::to(app()->getLocale(), 'faq/show/')}}"><i class="fa fa-eye"></i> Detail</a>| - link dengan parameter tertentu : blade : <a href="{{URL::to(app()->getLocale(),'faq/edit/'.$faq->id)}}"><i class="fa fa-pencil"></i> Edit</a>| route : Route::group(['prefix' => '{language}'], function () {   Auth::routes();   Route::put('faq/edit/{id_faq}', ['as' => 'edit',...

tunning atau optimize server saat error 502 atau 504

Ubuntu : - Cek nginx.conf besarkan countcurrent user - Cek www.conf di php-fpm besarkan pm.max_children dan sesuaikan dengan kondisi server bisa dilihat di top atau plugin glances service php7.3-fpm restart service php7.3-fpm status systemctl status nginx systemctl restart nginx

Fungsi fungsi laravel model

- multiple like atau cara menggunakan fungsi like dengan banyak kondisi : $proposals = $this->where('is_submitted','=', $is_submit)                       ->where(function($query) use ($keyword)                             {                               $query->where( 'judul','LIKE', '%'.$keyword.'%' )                                     ->orWhere( 'nama_organisasi','LIKE', '%'.$keyword.'%' );                             })                   ->paginate(10); - kondisi untuk query jika param tidak ada : $query = $this->join('kategori_dokumens', 'kategori_dokumens.id'...

Import restore data mysql secara parsial per kolom per tabel

Extracting a Table from a MySQL Dump Occasionally, I need to use the data in a single table from a full  MySQL  database backup dump. Ordinarily, you’d just import the database dump into MySQL and go. Unfortunately, if the dump file is several Gigabytes (even when compressed), it becomes time-consuming to  SCP  this file around and then load it into MySQL. In order to speed up the process, I extract the table I need from the full database dump. Then, I can take that table,  SCP  it to where I need it, load it into MySQL, and perform necessary operations with it. Fortunately, complicated programs and commands are not necessary for this: only  grep  and  sed  are needed. The first step is to determine the table structure from the decompressed MySQL database dump: BASH $ grep -n "Table structure" [ MySQL_dump_filename ] .sql Example: Let’s say we want to extract the  phpbb_config  table from a giant MySQL phpBB ...

mysql server

// https://www.shellhacks.com/mysql-show-users-privileges-passwords/ //melihat user dan host yang diizinkan SELECT user,host FROM mysql.user; //distinct atau grouping user berdasarkan username SELECT DISTINCT user FROM mysql.user; //update host user di mysql UPDATE mysql.user SET Host='%' WHERE Host='localhost' AND User='username'; SELECT -- * JSON_EXTRACT(object_json_namakolomnya, "$.penyedia_id") FROM permohonan_pembaruan_staging WHERE permohonan_pembaruan_id = '4512'; //buat user dan bisa di remote menggunakan IP lokal Server CREATE USER 'nama_usernya'@'%' IDENTIFIED BY 'passwordnya_apa'; GRANT ALL ON *.* TO 'nama_usernya'@'%'; FLUSH PRIVILEGES; - membuat user mysql dan privilege nya CREATE USER 'nama_user'@'192.168.ipnya' IDENTIFIED BY 'passXXXX'; GRANT ALL PRIVILEGES ON * . * TO 'nama_user'@'192.168.ipnya'; flush privileges; - cara meli...

html

Beauty html (mengubah script html menjadi rapih) : https://www.freeformatter.com/html-formatter.html#ad-output -> solusi select2 tidak muncul di modal box : -hilang tabindex="-1" di class modal box ( https://stackoverflow.com/questions/18487056/select2-doesnt-work-when-embedded-in-a-bootstrap-modal/33884094#33884094 ) -> solusi datepicker tidak muncul di modal html dalam modal :  < div class = "col-12 col-md-6" > < label class = "form-label" >< b > Tanggal Masuk </ b ></ label >< span style = " color: red; height: 500px;" > * </ span > < input type = "text" class = "form-control flatpickr-input" name = "tanggal_daftar" value = ...