laravel

  • There is time where we need to indentify is this the correct page / route we access before we proceed to the next step. Route  @if(action(‘FuntasticController@show’) == Request::url()) {} Name Route @if(Route::is(‘locationCluster’)){} or @if(route(‘namedRoute’) == Request::url()){}  

    Baca catatan

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

    Baca catatan

  • 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!’);…

    Baca catatan

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

    Baca catatan

  • 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: VOYAGER CRUDBOOSTER LARA…

    Baca catatan

  • Antara perkara penting dalam membangunkan applikasi adalah sistem pengurusan akses maklumat atau pun authentication & authorization. Laravel telah memudahkan kerja kita dengan menyediakan scaffolding authentication nya tersendiri. Anda hanya perlu install sahaja. Tetapi untuk install sistem authentication ini ia perlu dilaksanakan pada fresh setup SAHAJA. Execute code berikut untuk install Auth php artisan make:auth untuk…

    Baca catatan