• 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

Blender minimum system requirement

April 18, 2017 by ghazalitajuddin Leave a Comment

Park.

http://www.game-debate.com/games/index.php?g_id=5270&canMyGpuRunIt=Blender

Filed Under: General

Genesis Framework: Add extra div under primary navigation

February 10, 2017 by ghazalitajuddin Leave a Comment

Adding div below primary navigation

add_action( 'genesis_before_content_sidebar_wrap', 'feature_my_single_post_image' );

function feature_my_single_post_image() {

if( is_singular( 'page' ) ) {

global $post;

$size = 'full-size';
 $default_attr = array(
 'class' => "aligncenter attachment-$size $size",
 'alt' => $post->post_title,
 'title' => $post->post_title,
 );

printf( '<div class="example">%s</div>', genesis_get_image( array( 'size' => $size, 'attr' => $default_attr ) ) );

}

}

add_image_size('panoramic', 1140, 199, TRUE);

add_filter( 'image_size_names_choose', 'my_custom_image_sizes_choose' );

function my_custom_image_sizes_choose( $sizes ) {
 $custom_sizes = array(
 'panoramic' => 'Panoramic',
 );
 return array_merge( $sizes, $custom_sizes );
}

Credit: https://www.organicweb.com.au/17445/wordpress/genesis-move-featured-image/

Filed Under: Technology Tagged With: child theme, genesis

Mount & Umount Disk

January 23, 2017 by ghazalitajuddin Leave a Comment

List all 

diskutil list

Mount disk

diskutil mount /dev/disk2s1

Umount

diskutil unmount /dev/disk2s1

 

Filed Under: General, Technology Tagged With: linux, mac, macbook, unix

Laravel Special Method

January 18, 2017 by ghazalitajuddin Leave a Comment

There is a lot special functions that helps simplified our code like this

  1. find($id) takes an id and returns a single model. If no matching model exist, it returns null.
  2. findOrFail($id) takes an id and returns a single model. If no matching model exist, it throws an error.
  3. first() returns the first record found in the database. If no matching model exist, it returns null.
  4. firstOrFail() returns the first record found in the database. If no matching model exist, it throws an error.
  5. get() returns a collection of models matching the query.
  6. lists($column) returns a collection of just the values in the given column.
  7. toArray() converts the model/collection into a simple PHP array.

Looking for more? Visit here or https://laravel.com/docs/5.3/eloquent-collections.

Filed Under: Technology Tagged With: 5.3, collections, functions, helpers, laravel, methods, pre, special

Sentinel::Register() Vs Sentinel::RegisterAndActivate()

January 17, 2017 by ghazalitajuddin Leave a Comment

Sentinel::RegisterAndActivate()

       //Register the $request user and activate
	if(Sentinel::registerAndActivate($request->All())){

			//Search the new registered user
			$user = User::whereEmail($request->get('email'))->firstOrFail();

			//Bind the user to Activation Table
			$activation=Activation::create($userSentinel);

			//Assign A Profile To The New Registered User 
			$userProfile = new Profile();
			$userProfile->user_id = $user->id;
			$userProfile->smoked = $request->smoked;
			$userProfile->lat = 0.0;
			$userProfile->lng = 0.0;

			$user->profile()->save($userProfile);
			
			//Find role
			$role=Sentinel::findRoleBySlug('member')->firstOrFail();

			//Attach the user to the Role
			$role->users()->attach($user);


			return redirect()->back()->with('status','Registration Successful !');
		}else{
			return redirect()->back()->with('error','Registration Failed !');
			//return back()->withErrors($validator);
		}

Sentinel::Register()

                if($userSentinel = Sentinel::register($request->All())){

			//Search the new registered user
			$user = User::whereEmail($request->get('email'))->firstOrFail();

			//Bind the user to Activation Table
			$activation=Activation::create($userSentinel);

			//Assign A Profile To The New Registered User 
			$userProfile = new Profile();
			$userProfile->user_id = $user->id;
			$userProfile->smoked = $request->smoked;
			$userProfile->lat = 0.0;
			$userProfile->lng = 0.0;

			$user->profile()->save($userProfile);
			
			//Find role
			$role=Sentinel::findRoleBySlug('member')->firstOrFail();

			//Attach the user to the Role
			$role->users()->attach($user);

			return redirect()->back()->with('status','Registration Successful !');
		}else{
			return redirect()->back()->with('error','Registration Failed !');
			//return back()->withErrors($validator);
		}

 

Filed Under: General Tagged With: Register, RegisterAndActivate, sentinel

Laravel Middleware

January 17, 2017 by ghazalitajuddin Leave a Comment

Middleware is a class that have special function in Laravel.

Middleware placed in between the User and  Apps. 

Before you can access the Apps, Middleware will do his job first.

We can use Middleware to do several thing

  • Do you authenticated?
  • What is your role?
  • Do you authorized?
  • Can you perform this action?
  • etc
class MemberMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        //1. User must be authenticated
        //2. User must should be a "member"
        

        if(Sentinel::check() && Sentinel::getUser()->roles()->first()->slug == 'member')

            return $next($request);

        else

            return redirect('/login')->withErrors('Please login to access this area.');
        

        
    }
}

Another example

class ProfileMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        1. Get Profile Id
        2. Get Profile User Id
        3. User must own the Profile

        //$ProfileId = $request->segments()[1]; //boleh pakai
        //$profileId= Profile::find($this->route()->parameter('profileShow'));
        
        $ProfileId = $request->route()->parameter('id'); //boleh pakai
        $profile = Profile::findOrFail($ProfileId);

        if ($profile->user_id !== Sentinel::getUser()->id) {
            
           // dd($request->user()->id);
           // abort(403, 'Unauthorized action.');
              // return redirect('/profile')->withError('Permission Denied');
            return redirect()->back()->withErrors('Permission Denied!');
            }

        return $next($request);
        
    }
}

Another finest!

class ProfileMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //get User Id
        $UserId=$request->id;

        //get User Profile
        $profile=Profile::whereUserId($UserId)->first();

        if ($profile->user_id !== Sentinel::getUser()->id) {         
            return redirect()->back()->withErrors('Permission Denied!');
            }

        return $next($request);
        
    }
}

 

Filed Under: Technology Tagged With: Authentication, Authorization, laravel, middleware, sentinel

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 27
  • Page 28
  • Page 29
  • Page 30
  • Page 31
  • 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

Kuih Keria Viral di Kuantan???

Sarapan pagi di Warung Gulai Kawah

Sarapan pagi di Arked Sri Gambut

Lain macam Nasi Kerabu Mekla ni

Diet snack untuk abang-abang kacak

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. •