• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

GhazaliTajuddin.com

Another Kuantan Blogger

  • Home
  • Blog
    • Kuantan
    • Foods
    • Technology
    • Health
  • Stock Photography
    • Senarai Microstock Agency
    • Membuka akaun contributor Shutterstock.com
    • Tips untuk 10 keping gambar pertama Shutterstock.com
    • Mengapa Shutterstock.com reject gambar / submission
    • Model Release
    • Bagaimana withdraw earning daripada Fotolia
    • Bagaimana untuk mengisi keyword kepada imej dengan menggunakan Adobe Photoshop
You are here: Home / Blog

Blog

Submit Form Data

October 27, 2016 by ghazalitajuddin Leave a Comment

Dalam Laravel kita guna GET method untuk paparkan form

Route:get ('/courer/create',CouriersController@create');

Tetapi kita gunakan POST untuk submit data. Ia tidak disimpan dalam cache dan parameter tidak disimpan dalam History, lebih secure.

Tambah pada routes.php (web.php utk versi Laravel versi 5.3 keatas)

Route:post('/courier','CouriersController@store');

Untuk memastikan data yang disimpan dalam table, kita akan lakukan validation kepada store action dengan menggnakan CourierFormRequest.

Tambah pada CouriersController.php sebelum class CouriersController

use App\Http\Requests\CourierFormRequest;
class CouriersController extends Controller
{

Tambah pada CouriersControler.php method store

public function store(CourierFormRequest $request)
{
return $request->all();
}

What is TokenMismatchException?
For security purposes, Laravel now requires a token to be sent when using the POST method. If you
don’t send any token, it will throw an error.

Tambah code berikut pada form, dibawah tag <form> utk security

<input type="hidden" name="_token" value="{!! csrf_token() !!}">

Tambah code berikut untuk paparan error jika ada field yang tidak diisi.

@foreach ($errors->all() as $error)
<p class="alert alert-danger">{{ $error }}</p>
@endforeach

Tambah code berikut untuk paparan success jika berjaya.

@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif

Ringkasan:

  1. Edit Route
    • Gunakan method GET untuk paparan form (route.php)
    • Gunakan method POST untuk dapatkan data (route.php)
  2. Create Form Request
    • Gunakan FormRequest untuk validate data form (CourierFormRequest.php)
  3. Edit Controller
    • Tambah sebelum class use App\Http\Requests\TicketFormRequest;
    • Tambah method store()
  4. Edit view
    1. Tambah method post <form method=”post”>
    2. Tambah CSRF Token bawah tag <form> <input type=”hidden” name=”_token” value=”{!! csrf_token() !!}”>
    3. Tambah foreach semak error bawah tag <form> @foreach ($errors->all() as $error) <p class=”alert alert-danger”>{{ $error }}</p>
      @endforeach 
    4. Tambah foreach success jika berjaya bawah form tag @if (session(‘status’))
      <div class=”alert alert-success”>
      {{ session(‘status’) }}
      </div>
      @endif

 

 

 

 

 

Filed Under: General Tagged With: create submit form, create submit form laravel, csrf, FormRequest, laravel, submit form

After a while…

October 22, 2016 by ghazalitajuddin Leave a Comment

Salam. Hari ni aku nak berblog.

Tapi time aku nak bercerita itulah line tenet rumah takde. Sempat pulak nak membebel hahaha. Time aku nak sharing pasal programming ka, pasal stock photo ka, pasal bebas rokok elok ada je internet hahaha. Ini kali kita sembang pasal life lah. Mungkin sebab itu line kong ini malam. Sumbak. Hahaha.

[Read more…] about After a while…

Filed Under: General, Lifestyle

Pembangunan WordPress Plugin Yang Menggunakan Shortcodes

May 16, 2016 by ghazalitajuddin

Develop pulgin yang menggunakan shortcodes ini perlu tahu beberapa perkara

  1. Widget text tak support shortcodes secara default.
    • Jika anda ingin menggunakan shortcodes pada bahagian widget. Pasti anda akan gunakan Widget Text.
    • Tetapi secara defaultnya, widget text tak support shortcodes.
    • Anda perlu aktifkan seperti berikut
      //Remove the filter if it already exists
      remove_filter('widget_text', 'do_shortcode');
      
      //Add the filter to apply the shotcode action to widget text
      add_filter('widget_text', 'do_shortcode');
  2. Guna return, bukan echo.
    • Sekiranya anda ingin memaparkan suatu keputusan melalui shortcodes anda, anda akan perasan sekiranya menggunakan echo, hasil keputusan berkenaan akan di paparkan sebelum atau diluar daripada kawasan <div> sepatutnya.
    • Untuk itu elakkan gunakan echo, kerana secara asasnya formatnya adalah menggunakan return.

      Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. This is similar to the way filter functions should behave, in that they should not produce expected side effects from the call, since you cannot control when and where they are called from.

    • Contohnya seperti berikut
      function callmyshortcode() {
      return 'This is correct';
      }
      add_shortcode('correctshortcode', 'callmyshortcode');
      
      /*--------------------
      function callmyshortcode() {
      echo 'This is wrong';
      }
      add_shortcode('wrongshortcode', 'callmyshortcode');
      --------------------*/

Reference: Wordperss Function Reference/add shortcode

Filed Under: General Tagged With: echo, return, shortcodes, wordpress

Kalendar Hijrah Islam

May 8, 2016 by ghazalitajuddin Leave a Comment

Dah lama aku mencari algorithm Hijrah ni.

Kebanyakan kalendar Hijrah ni menggunakan 2 algorithm

  • Um Al Qura algorithm
  • Tabular Algorithm

Tapi buat masa ni baru jumpa Um Al Qura algorithm dibuat berdasarkan hasil kerja Robert Harry van Gent work. Beliau menulis algorithm bagi menukankan tarikh gregorian kepada hijriah.

Boleh dapatkan library javascript menukar tarikh daripada Geregorian kepada Hijriah di Github https://github.com/talomaireeni/Umm-Al-Qura-Calendar.

Al-habib.info ada kongsikan calculation yang telah dipermudahkan disini.

function gmod(n,m){
	return ((n%m)+m)%m;
}

function kuwaiticalendar(adjust){
	var today = new Date();
	if(adjust) {
		adjustmili = 1000*60*60*24*adjust; 
		todaymili = today.getTime()+adjustmili;
		today = new Date(todaymili);
	}
	day = today.getDate();
	month = today.getMonth();
	year = today.getFullYear();
	m = month+1;
	y = year;
	if(m<3) {
		y -= 1;
		m += 12;
	}

	a = Math.floor(y/100.);
	b = 2-a+Math.floor(a/4.);
	if(y<1583) b = 0;
	if(y==1582) {
		if(m>10)  b = -10;
		if(m==10) {
			b = 0;
			if(day>4) b = -10;
		}
	}

	jd = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524;

	b = 0;
	if(jd>2299160){
		a = Math.floor((jd-1867216.25)/36524.25);
		b = 1+a-Math.floor(a/4.);
	}
	bb = jd+b+1524;
	cc = Math.floor((bb-122.1)/365.25);
	dd = Math.floor(365.25*cc);
	ee = Math.floor((bb-dd)/30.6001);
	day =(bb-dd)-Math.floor(30.6001*ee);
	month = ee-1;
	if(ee>13) {
		cc += 1;
		month = ee-13;
	}
	year = cc-4716;

	if(adjust) {
		wd = gmod(jd+1-adjust,7)+1;
	} else {
		wd = gmod(jd+1,7)+1;
	}

	iyear = 10631./30.;
	epochastro = 1948084;
	epochcivil = 1948085;

	shift1 = 8.01/60.;
	
	z = jd-epochastro;
	cyc = Math.floor(z/10631.);
	z = z-10631*cyc;
	j = Math.floor((z-shift1)/iyear);
	iy = 30*cyc+j;
	z = z-Math.floor(j*iyear+shift1);
	im = Math.floor((z+28.5001)/29.5);
	if(im==13) im = 12;
	id = z-Math.floor(29.5001*im-29);

	var myRes = new Array(8);

	myRes[0] = day; //calculated day (CE)
	myRes[1] = month-1; //calculated month (CE)
	myRes[2] = year; //calculated year (CE)
	myRes[3] = jd-1; //julian day number
	myRes[4] = wd-1; //weekday number
	myRes[5] = id; //islamic date
	myRes[6] = im-1; //islamic month
	myRes[7] = iy; //islamic year

	return myRes;
}
function writeIslamicDate(adjustment) {
	var wdNames = new Array("Ahad","Ithnin","Thulatha","Arbaa","Khams","Jumuah","Sabt");
	var iMonthNames = new Array("Muharram","Safar","Rabi'ul Awwal","Rabi'ul Akhir",
	"Jumadal Ula","Jumadal Akhira","Rajab","Sha'ban",
	"Ramadan","Shawwal","Dhul Qa'ada","Dhul Hijja");
	var iDate = kuwaiticalendar(adjustment);
	var outputIslamicDate = wdNames[iDate[4]] + ", " 
	+ iDate[5] + " " + iMonthNames[iDate[6]] + " " + iDate[7] + " AH";
	return outputIslamicDate;
}

Untuk menggunakan script atas seperti berikut

document.write(writeIslamicDate());

Other reference

  • http://www.staff.science.uu.nl/~gent0113/islam/islam_tabcal.htm
  • http://calndr-l.10958.n7.nabble.com/Umm-al-Qura-calendar-algorithms-td6422.html
  • http://www.phpclasses.org/ucal by http://aziz.oraij.com/
  • http://www.phpclasses.org/package/9435-PHP-Convert-and-manipulate-Hijri-dates.html

 

 

Filed Under: General

Bagaimana menggunakan Font Awesome dalam Laravel

April 19, 2016 by ghazalitajuddin Leave a Comment

Kejadah Font Awesome? Baca sini.

Add dalam head / master layout view

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel='stylesheet' type='text/css'>

Cara guna, contoh nak add button facebook dengan icon “f”.

<div class="quote"><a href="/login/facebook"> <div class="btn btn-md btn-primary"> <i class="fa fa-facebook"></i> Login with Facebook </div></a></div>

pZzc4

Banyak lagi boleh tengok disini.

Filed Under: General

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

April 18, 2016 by ghazalitajuddin Leave a Comment

Biasa berlaku pada pengguna window.

Ko download http://curl.haxx.se/ca/cacert.pem (mesti download dalam forman .pem, bukan .txt)

Pastikan save dalam directory yang sama dengan PHP.INI (Biasanya C:/XAMPP/PHP/)

Buka PHP.INI

Gantikan link ke file yang anda download tadi dengan actual path baru.

[cURL] curl.cainfo="D:\xampp\php\cacert.pem"

Referece: Here

Filed Under: General

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 31
  • Page 32
  • Page 33
  • Page 34
  • Page 35
  • Interim pages omitted …
  • Page 57
  • Go to Next Page »

Primary Sidebar

“Solat. Sabar. Syukur. Senyum. Sedekah.”

For Collaboration, Events & Review, kindly contact me at +6016[-]9212092 or click Whatsapp button on this page.

Sponsor

Recent Posts

BadMethodCallException Method Illuminate\Database\Eloquent\Collection::roles does not exist.

User Roles And Permissions Without Package Laravel 10

Laravel Many To Many Relationship

Makan malam bersama keluarga di Awangan Palace

Sarapan pagi di Warung Gulai Kawah

Recent Comments

  • helmi on Personal Tips Berhenti Merokok
  • ghazalitajuddin on Personal Tips Berhenti Merokok
  • helmi on Personal Tips Berhenti Merokok
  • ghazalitajuddin on Nasi Lemak Kukus Restoran Zaman. Otai masih berbisa.
  • ghazalitajuddin on Air tangki radiator Proton Exora cepat kering? Cuba tukar penutup radiator!
  • Mal on Nasi Lemak Kukus Restoran Zaman. Otai masih berbisa.
  • Firdaus on Air tangki radiator Proton Exora cepat kering? Cuba tukar penutup radiator!

My Link

  • Takaful Insurance Web

JJCM

Aneka Kuih Tradisional

Nasi Ayam Papa ~ Best Hainan Chicken Rice In Town

7 Lokasi Nasi Dagang Terbaik di Kuantan

Lunch di Nasi Kukus Alom

Breakfast di De Aisyah Kuantan

Tags

bebas rokok berhenti merokok breakfast Controller Framework Gezzeg Photography & Design health jalan-jalan cari makan jalan-jalan cari makan kuantan jjcm jjcm kuantan Jurufoto Kuantan Kuantan Kuantan Photographer kuantan programmer kuantan web developer kuantan webmaster laravel merokok merbahayakan kesihatan model MVC nikmat rokok OOP Pahang Pahangtourism pahang tourism Photo Manipulation PHP rajalanun retired smoking revisit pahang 2018 shutterstock stop smoking stop smoking tips stop smoking withdrawal symptom tips tips berhenti merokok View visit malaysia 2020 visit pahang visitpahang white wordpress yii Yii Framework

Recent Posts

  • BadMethodCallException Method Illuminate\Database\Eloquent\Collection::roles does not exist.
  • User Roles And Permissions Without Package Laravel 10
  • Laravel Many To Many Relationship
  • Makan malam bersama keluarga di Awangan Palace
  • Sarapan pagi di Warung Gulai Kawah

Copyright © 2025 — Ghazali Tajuddin • All rights reserved. •