Saturday, October 17, 2015

Cara partials views header, content, footer blade laravel

Cara partials view header, content, footer blade laravel gimana sih.? Masih bingung dengan blade nya laravel.? sama  :lol:  , mari kita belajar bersama. Ok point aja Cara partials view header, content, footer blade laravel. Pertama perhatikan struktur folder laravel bagian view nya terlebih dahulu, default phat view laravel ada di resource.


struktur_folder_resource_view_laravel

Kisarnya sperti itu struktur foldernya. Dengan tmbahan beberapa folder. Di resource view akan saya rubah folder-foldernya yaitu dengan menambahkan folder dengan nama include yg isinya akan ada

  1. footer

  2. nav

  3. sidebar


Dan juga menghapus pages. Folder layouts nanti akan saya isi dengan tampilan / isi content yang berbeda-beda. Setelah saya rubah maka akan menjadi seperti gambar di bawah ini

struktur_folder_resource_view_laravel_change

Disini template nya saya menggunakan Bootstrap.

Ok Langsung saja buat file-file yang di butuhkan dengan nama index.blade.php letakan di dalam folder views

index.blade.php


<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="{{ asset('favicon.ico') }}">
        <title>Stackode with laravel</title>
        <link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
        <link href="{{ asset('css/custom.css') }}" rel="stylesheet">
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        @include('include.navigation')
        <div class="container">
            @yield('content')
        </div>
        @include('include.footer')
        <script src="{{ asset('js/jquery.min.js') }}"></script>
        <script src="{{ asset('js/bootstrap.min.js') }}"></script>
    </body>
</html>

Selanjutnya buat file navigation.blade.php simpant di folder views->include->navigation.blade.php

navigation.blade.php


<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Menu</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">Stackode</a>
    </div>
    <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            <li class="{{ isActiveRoute('home') }}">{!! HTML::linkRoute('home', 'Home') !!}</li>
            <li class="{{ isActiveRoute('about') }}"><a href="#about">About</a></li>
            <li class="{{ isActiveRoute('blogs') }}">{!! HTML::linkRoute('blogs', 'Blog') !!}</li>
            <li class="{{ isActiveRoute('contact') }}"><a href="#contact">Contact</a></li>            
        </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>

Selanjutnya buat file sidebar.blade.php simpant di folder views->include->sidebar.blade.php

sidebar.blade.php


<div class="col-md-4">
    <div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">Search</h3>
        </div>
        <div class="panel-body">
        {!! Form::open(['url' => 'foo/bar', 'method'=>'GET']) !!}
        {!! Form::text('search','Search',['class'=>'form-control']) !!}
        {!! Form::close() !!}
        </div>
    </div>

    <div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">Recent Post</h3>
        </div>
        <div class="panel-body">
        <ul class="list-group">
            <li class="list-group-item">{!! HTML::link('/cara-partials-view-blader-laravel','Cara partials view header, content, footer blade laravel') !!}</li>
            <li class="list-group-item">{!! HTML::link('/cara-partials-view-blader-laravel','Cara partials view header, content, footer blade laravel') !!}</li>
            <li class="list-group-item">{!! HTML::link('/cara-partials-view-blader-laravel','Cara partials view header, content, footer blade laravel') !!}</li>
            <li class="list-group-item">{!! HTML::link('/cara-partials-view-blader-laravel','Cara partials view header, content, footer blade laravel') !!}</li>
            <li class="list-group-item">{!! HTML::link('/cara-partials-view-blader-laravel','Cara partials view header, content, footer blade laravel') !!}</li>
          </ul>    
        </div>
    </div>
</div>

Selanjutnya buat file footer.blade.php simpant di folder views->include->footer.blade.php

footer.blade.php


<footer class="footer">
    <div class="container">
        <p class="text-muted">Copyright &copy; 2015, Stackode</p>
    </div>
</footer>

Selanjutnya buat file home.blade.php simpant di folder views->layouts->home.blade.php

home.blade.php


@extends('index')
@section('content')
<div class="page-header">
    <h1>Welcome to Stackode</h1>
</div>
<p class="lead">This build with laravel 5 {!! HTML::link('https://www.stackode.tk/', 'Stackode Lab', ['class'=>'btn btn-danger', 'target'=>'_blank']) !!}</p>
@endsection

Selanjutnya buat file blog.blade.php simpant di folder views->layouts->blog.blade.php

blog.blade.php


@extends('index')
@section('content')
<div class="page-header">
    <h1>Blog</h1>
</div>
<div class="col-md-12">
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading">
              <h3 >Cara partials view header, content, footer blade laravel</h3>
              <p><small>At : 10-10-2015</small>,<small>On : Laravel</small>,<small>Tag : Laravel</small></p>
            </div>
            <div class="panel-body">
              <p>
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit..    
              </p>    
            </div>
            <div class="panel-footer">
                {!! HTML::link('/cara-partials-view-blader-laravel','Readmore',['class'=>'btn btn-info']) !!}
            </div>
        </div>
        <hr>
        <div class="panel panel-default">
                <div class="panel-heading">
                  <h3 >Cara partials view header, content, footer blade laravel</h3>
                  <p><small>At : 10-10-2015</small>,<small>On : Laravel</small>,<small>Tag : Laravel</small></p>
                </div>
                <div class="panel-body">
                  <p>
                      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit..    
                  </p>    
                </div>
                <div class="panel-footer">
                    {!! HTML::link('/cara-partials-view-blader-laravel','Readmore',['class'=>'btn btn-info']) !!}
                </div>
            </div>
        </div>
        
    @include('include.sidebar')

</div>

@endsection

Nah itu lah file-file partials templatenya. Selanjutnya kita buat router untuk mencoba melihat hasilnya di app->Http->routes.php

Routes.php


Route::get('/', ['as'=>'home',function () {
return View::make('layouts.home');
}]);

Route::get('/blog', ['as'=>'blogs', function () {
return View::make('layouts.blog');
}]);

Setelah semuanya sudah di buat maka folder + isinya akan seperti ini

struktur_folder_resource_view_laravel_finish

Nah selanjutnya jalankan di browser dengan link http://localhost/onmy/laravel_oprek/public/ ( sesuai dengan yang punya anda ).

Screenshoooooott ::

home-blade

blog-blade

Nah hasilnya seperti itu.

Ok Selesai sudah Cara partials views header, content, footer blade laravel.

Link Download Source Code

Vendor Laravel nya Link Download

Form dan HTML Laravel

Form dan HTML Laravel



Installation


Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html.
"require": {
"laravelcollective/html": "~5.0"
}

Next, update Composer from the Terminal:
composer update

Next, add your new provider to the providers array of config/app.php:
  'providers' => [
// ...
'Collective\Html\HtmlServiceProvider',
// ...
],

Finally, add two class aliases to the aliases array of config/app.php:
  'aliases' => [
// ...
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
// ...
],

Looking to install this package in Lumen? First of all, making this package compatible with Lumen will require some core changes to Lumen, which we believe would dampen the effectiveness of having Lumen in the first place. Secondly, it is our belief that if you need this package in your application, then you should be using Laravel anyway.


Opening A Form


Opening A Form


{!! Form::open(array('url' => 'foo/bar')) !!}
//
{!! Form::close() !!}

By default, a POST method will be assumed; however, you are free to specify another method:
echo Form::open(array('url' => 'foo/bar', 'method' => 'put'))

Note: Since HTML forms only support POST and GET, PUT and DELETE methods will be spoofed by automatically adding a _method hidden field to your form.

You may also open forms that point to named routes or controller actions:
echo Form::open(array('route' => 'route.name'))

echo Form::open(array('action' => 'Controller@method'))

You may pass in route parameters as well:
echo Form::open(array('route' => array('route.name', $user->id)))

echo Form::open(array('action' => array('Controller@method', $user->id)))

If your form is going to accept file uploads, add a files option to your array:
echo Form::open(array('url' => 'foo/bar', 'files' => true))


CSRF Protection


Adding The CSRF Token To A Form


Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. If you use the Form::open method with POST, PUT or DELETE the CSRF token will be added to your forms as a hidden field automatically. Alternatively, if you wish to generate the HTML for the hidden CSRF field, you may use the token method:
echo Form::token();

Attaching The CSRF Filter To A Route


Route::post('profile', array('before' => 'csrf', function()
{
//
}));


Form Model Binding


Opening A Model Form


Often, you will want to populate a form based on the contents of a model. To do so, use the Form::model method:
echo Form::model($user, array('route' => array('user.update', $user->id)))

Now, when you generate a form element, like a text input, the model's value matching the field's name will automatically be set as the field value. So, for example, for a text input named email, the user model's email attribute would be set as the value. However, there's more! If there is an item in the Session flash data matching the input name, that will take precedence over the model's value. So, the priority looks like this:

  1. Session Flash Data (Old Input)

  2. Explicitly Passed Value

  3. Model Attribute Data


This allows you to quickly build forms that not only bind to model values, but easily re-populate if there is a validation error on the server!
Note: When using Form::model, be sure to close your form with Form::close!


Labels


Generating A Label Element


echo Form::label('email', 'E-Mail Address');

Specifying Extra HTML Attributes


echo Form::label('email', 'E-Mail Address', array('class' => 'awesome'));

Note: After creating a label, any form element you create with a name matching the label name will automatically receive an ID matching the label name as well.


Text, Text Area, Password & Hidden Fields


Generating A Text Input


echo Form::text('username');

Specifying A Default Value


echo Form::text('email', 'example@gmail.com');

Note: The hidden and textarea methods have the same signature as the text method.

Generating A Password Input


echo Form::password('password');

Generating Other Inputs


echo Form::email($name, $value = null, $attributes = array());
echo Form::file($name, $attributes = array());


Checkboxes and Radio Buttons


Generating A Checkbox Or Radio Input


echo Form::checkbox('name', 'value');

echo Form::radio('name', 'value');

Generating A Checkbox Or Radio Input That Is Checked


echo Form::checkbox('name', 'value', true);

echo Form::radio('name', 'value', true);


Number


Generating A Number Input


echo Form::number('name', 'value');


Date


Generating A Date Input


echo Form::date('name', \Carbon\Carbon::now());


File Input


Generating A File Input


echo Form::file('image');

Note: The form must have been opened with the files option set to true.


Drop-Down Lists


Generating A Drop-Down List


echo Form::select('size', array('L' => 'Large', 'S' => 'Small'));

Generating A Drop-Down List With Selected Default


echo Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S');

Generating A Grouped List


echo Form::select('animal', array(
'Cats' => array('leopard' => 'Leopard'),
'Dogs' => array('spaniel' => 'Spaniel'),
));

Generating A Drop-Down List With A Range


echo Form::selectRange('number', 10, 20);

Generating A List With Month Names


echo Form::selectMonth('month');


Buttons


Generating A Submit Button


echo Form::submit('Click Me!');

Note: Need to create a button element? Try the button method. It has the same signature as submit.


Custom Macros


Registering A Form Macro


It's easy to define your own custom Form class helpers called "macros". Here's how it works. First, simply register the macro with a given name and a Closure:
Form::macro('myField', function()
{
return '<input type="awesome">';
});

Now you can call your macro using its name:

Calling A Custom Form Macro


echo Form::myField();


Generating URLs


link_to


Generate a HTML link to the given URL.
echo link_to('foo/bar', $title = null, $attributes = array(), $secure = null);

link_to_asset


Generate a HTML link to the given asset.
echo link_to_asset('foo/bar.zip', $title = null, $attributes = array(), $secure = null);

link_to_route


Generate a HTML link to the given named route.
echo link_to_route('route.name', $title = null, $parameters = array(), $attributes = array());

link_to_action


Generate a HTML link to the given controller action.
echo link_to_action('HomeController@getIndex', $title = null, $parameters = array(), $attributes = array());

Sumber Laravel Collection

Tuesday, June 23, 2015

Install Google Chrome on Fedora 22/21/20/19/18, CentOS 7.1, Red Hat (RHEL) 7.1

Cara install Google Chrome di Fedora 22/21/20/19/18, CentOS 7.1, Red Hat (RHEL) 7.1 lewat Command Line ( Terminal ).

Pertama masuk ke user root :
sudo -i

## OR ##

su -

Setelah itu Enable Google Yum Repository dengan cara berikut ( Copas di terminal )

1. Google Chrome Stable Version


cat << EOF > /etc/yum.repos.d/google-chrome.repo

[google-chrome]

name=google-chrome - \$basearch

baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch

enabled=1

gpgcheck=1

gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

EOF

Setelah itu Install Google chrome dengan langkah seperti berikut ini :



## Install Google Chrome Stable version ##

## Fedora 22 ##

dnf install google-chrome-stable


## Fedora 21/20/19/18 and CentOS/RHEL 7.1 ##

yum install google-chrome-stable

2. Google Chrome Beta Version


## Install Google Chrome Beta version ##

## Fedora 22 ##

dnf install google-chrome-beta


## Fedora 21/20/19/18 and CentOS/RHEL 7.1 ##

yum install google-chrome-beta

3. Google Chrome Unstable Version


## Install Google Chrome Unstable version ##

## Fedora 22 ##

dnf install google-chrome-unstable


## Fedora 21/20/19/18 and CentOS/RHEL 7.1 ##

yum install google-chrome-unstable

Nah begitulah Install Google Chrome on Fedora 22/21/20/19/18, CentOS 7.1, Red Hat (RHEL) 7.1

 

Thursday, June 11, 2015

Tutorial Membuat file robots.txt pada website

Tutorial Membuat file robots.txt pada website -  Robot yang satu ini bukan robot ( power rangers ), tapi robots ini merupakan file yang diperlukan oleh sebuah website/ blog supaya terindeks dengan cepat oleh search engine ( Mesin Pencari ) seperti Google, Yahoo, Bing, dan lain lain. Dengan adanya robots.txt search engine seperti Google akan lebih mudah meng-index website / blog kita. Robots.txt merupakan informasi bagi search engine mengenai direktori mana yang boleh diakses atau tidak. Selain itu, dengan robots.txt kita bisa memblock search engine agar tidak mengakses website/ blog kita.




[caption id="attachment_383" align="aligncenter" width="282"]robots-txt-whendy-blog robots-txt-whendy-blog[/caption]



contoh robots.txt


User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content
User-agent: Mediapartners-Google
Allow: /
User-agent: Adsbot-Google
Allow: /
User-agent: Googlebot-Image
Allow: /
User-agent: Googlebot-Mobile
Allow: /
Sitemap: https://whendy.net/sitemap.xml

Ganti https://whendy.net/sitemap.xml dengan lokasi sitemap.xml anda.

Thursday, February 26, 2015

Install Laravel tanpa menggunakan Composer

Salam semuanya, saya akan membagikan cara Install Laravel tanpa menggunakan Composer.  Mungkin dari teman-teman ada yang masih bingung bagaimana caranya, yang mana selama ini mungkin hanya tau bahwa Cara Install Laravel dengan Composer saja.


Baiklah Langsung saja ke poinnya, Bagaimana sih caranya.?




  1. Pastikan bahwa laptop/PC anda sudah terinstall web server (Apache, nginx, etc) serta pendukung lainya.

  2. Pastikan juga Extension Required for Laravel sudah di aktifkan. Extension/Server Requirements yang diperlukan:



  • PHP >= 5.4

  • Mcrypt PHP Extension

  • OpenSSL PHP Extension

  • Mbstring PHP Extension

  • Tokenizer PHP Extension


3.  Setelah itu Download LaraPack anda bisa download langsung. Page nya Visit page.

Setelah selesai downloadnya Coppy kan LaraPack ke webserver anda, jalankan di browser anda.

[caption id="attachment_309" align="aligncenter" width="521"]larapack larapack[/caption]

Nah selesai sudah install / memasang Laravel ke webserver anda. Selamat belajar.