Skip to main content

Laravel Blade : Perbedaan IF dan UNLESS





bill.web.id, hello guys, beberapa hari lalu saya bikin module laravel buat summerschool di kampus saya, karna bikin module nggk boleh asal asalan akhirnya saya coba review lagi dokumentasi laravel, pas nyampe bab blade template engine saya mendapati beberapa directive baru salah satunya yaitu unless. directive baru ini sama sama ada di kelas percabangan, menemani if else, nah sekarang pertanyaannya adalah bedanya unless dengan if else apa?.

Baca juga :

oke, jika kalian disini sudah faham tentang apa itu if else, maka unless adalah kebalikan dari if else. contoh :


@if(auth::check())

{{ "it will printed when user was loged in" }}

@endif

note : kalimat di dalam percabangan akan di cetak apabila percabangan bernilai true

@unless(auth::check())

{{ "it will printed when user was not loged in" }}

@endif

note : kalimat di dalam percabangan akan di cetak apabila percabangan bernilai false

sampai sini sudah faham belom? okeh, saya kasih clue lagi nih. apabila directive if valuenya di negasi maka hasilnya akan sama kayak menggunakan unless . 

contoh :

@if(!Auth::check()) sama dengan @unless(Auth::check())

saya kira sampai sini sudah faham yah, jadi intinya unless adalah kebalikan dari if else. okeh, semoga hari kalian menyenangkan, tetap pantengin blog saya ya. dan jangan lupa tunggu ebook laravel gratis dari saya. thanks ^_^

Popular posts from this blog

Automatic API Documentation Swagger in Golang #GolangDev

pixabay.com In this article, I'll explain how to generate an API blueprint instantly using SwagGo in Golang. API blueprint is a document that contains a bunch of API endpoints, its slickly same as documentation but less description, it's allow another programmer to read and see all the available endpoint and try it out with sandbox feature. Swagger is one of the most used API blueprints right now, it's available in free but limited usage. if you wanna use the free credit, you need to understand YAML notation, you can read the example notation in swagger official documentation. but again, it's really hard and takes an expensive time to arranges all the notation to achieve a good API blueprint. fortunately, there are tools in Golang that allow us to generate the YAML notation and automatically generate the blueprint page with only using markup notation, and it's FREE unlimited for self-host, insane right? SwagGo tools are available here , the documentation is very cl...

Playing with Hooks in Gorm #GolangDev

Pixabay Hello everyone, I would like to share some tricks in gorm, the Idea of this tricks is to execute a command or code statement in the middle of an ORM operation, if you ever know about trigger in the query language, then hooks is just kinda like that. Hooks could execute statement in some events such as: beforeCreate, beforeUpdate, afterCreate,  and afterUpdate . those event is similar as a trigger,  when the trigger is executed in DBMS layer, hooks are executed in the application layer. In my real case, my current company has different convention of naming database column, so when I try to implement ORM, a lot of columns such as created_at, updated_at and deleted_at can't be generated automatically. also if you have a custom UUID you could pass the value UUID generator into hooks before the insert is executed. for more detail let's jump into code : # Explanation Above code containing model struct, and several methods from gorm to serve model, TableName method used to d...

OpenVPN Alternatif Solusi Menanggulangi Blokir dari KOMINFO

Sejak akhir juli 2022 kemaren indonesia di gegerkan dengan tindakan kominfo atas diblokirnya banyak platform digital karna tidak mendaftar PSE, terutama paypal dan plaform game (steam, epic game dll). keputusan ini semakin membuat netizen geram dikarenakan platform judi online malah disetujui untuk beroperasi karna sudah daftar PSE. Jujur menurut saya memang keputusan ini sejak awal saya dengar sudah mengada-ada karna sangat aneh memblokir semua platform digital yang jumlahnya tidak terhitung banyaknya dan hanya membolehkan akses platform yang sudah mendaftar yang jumlahnya hanya ratusan.  saya sebagai developer juga merasa aneh banget ini kebijakan apalagi platform development juga banyak yang di blacklist oleh kominfo seperti, github, gitlab, bitbucket, even website CDN pun di blacklist. astaga wkwkwk. anyway terlepas dari kebijakan konyol ini, saya mau berbagi tips cara agar tetep bisa mengakses semua platform tersebut tanpa ada halangan, yaitu dengan menggunakan VPN. banyak ban...