• 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

Laravel Handling Exceptions

January 17, 2017 by ghazalitajuddin Leave a Comment

This is examples how Laravels handle exceptions.

try{
..
.. Business Logic ..
..
}
catch(ThrottlingException $e){
$delay = $e->getDelay();
return redirect()->response->withErrors("You are banned for $delay seconds.");
}
catch(NotActivatedException $e){
return redirect()->response->withErrors("You account is not activated.");
}

Not to forget at the top of the class

use Cartalyst\Sentinel\Checkpoints\ThrottlingException;
use Cartalyst\Sentinel\Checkpoints\NotActivatedException;

Filed Under: General Tagged With: exceptions, laravel, NotActivatedException, sentinel, ThrottlingException

Laravel Getting Current Page

January 17, 2017 by ghazalitajuddin Leave a Comment

There is time where we need to indentify is this the correct page / route we access before we proceed to the next step.

  1. Route 
     @if(action('FuntasticController@show') == Request::url()) {}
  2. Name Route
    @if(Route::is('locationCluster')){}

    or

    @if(route('namedRoute') == Request::url()){}

     

Filed Under: General, Technology Tagged With: laravel, route, route::is()

Laravel Logout Using Post Method

January 13, 2017 by ghazalitajuddin Leave a Comment

In terms of security, it is not wise to use GET method to logout from your applications.

To make more secure, use POST method.

<li> 
<a href="{{ url('/logout') }}" 
onclick="event.preventDefault(); 
document.getElementById('logout-form').submit();"> 

Logout 

</a> 

<form id="logout-form" action="{{ url('/logout') }}" 
method="POST" style="display: none;"> 

{{ csrf_field() }} 
</form> 

</li>

In your controller

public function logout()
{
if(Sentinel::logout()){
return redirect('/');
}
}

 

Filed Under: Kuantan Web Developer, Technology Tagged With: laravel, logout, method, post logout, secure, sentinel

Error Message

January 10, 2017 by ghazalitajuddin Leave a Comment

Instead of

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

Do like this

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

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

Or

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

In controller

return redirect()->back()->with('status','Process is successfully done!');

 

 

Filed Under: General Tagged With: error, FormRequest, laravel, request, response, return, session, success

Laravel Eloquent Relationship

January 8, 2017 by ghazalitajuddin Leave a Comment

Model: Record (id,user_id, status_id, date, note, timestamp)

class Record extends Model
{
function status(){
return $this->belongsTo('App\SmokingStatus','status_id');
}
}

Model: Status(id,name)

class Status extends Model
{
function record()
{
return $this->hasMany('App\Record','id','status_id');
}
}

If you try to access it directly like this {{$record->status->name }} it will return “Trying to get property of non-object”.

You need to access the user status value like this in view

{{ @$record->status->name }} or {{ $record->status['name'] }}

Filed Under: General, Technology Tagged With: eloquent, laravel, non-object, trying to get property of non-object, View

Laravel Admin Package

November 23, 2016 by ghazalitajuddin Leave a Comment

Ada banyak package yang dibangunkan oleh komuniti Laravel ni.

Kesemua package ini boleh didapati di http://packalyst.com/ yang merupakan direktori yang menyenaraikan semua package yang boleh digunakan untuk projek anda.

Paling best, kebanyakannya free.

Antara package yang penting adalah Admin Package.

Tak payah dah nak buang masa nak develop sendiri.

Antara package yang feymes:

  1. VOYAGERscreen-shot-2016-11-23-at-9-19-01-pm
  2. CRUDBOOSTERscreen-shot-2016-11-23-at-9-23-06-pm
  3. LARA ADMINscreen-shot-2016-11-23-at-9-26-05-pm
  4. LARAVEL PANELscreen-shot-2016-11-23-at-10-46-47-pm
  5. QUICK ADMINscreen-shot-2016-11-23-at-10-57-55-pm

Filed Under: General, Kuantan Web Developer Tagged With: admin, crud booster, lara admin, laravel, laravel panel, package, packagist, quick admin, voyager

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

7 Lokasi Nasi Dagang Terbaik di Kuantan

Laksam Terbaik Di Kuantan, Sanggup Menunggu Sejam

Rojak Pak Lah Taman Gelora

Kuih Akok Kedut Kelantan

Sarapan pagi di Warung Nasi Dagang Hujung Minggu Besut

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