sukohi/form-action

Your package description here.

2.0.2 2016-07-14 18:02 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:56:25 UTC


README

A Laravel package to manage action URL of form tag. (This package is for Laravel 5+)

Installation

Execute composer command.

composer require sukohi/form-action:2.*

Register the service provider in app.php

'providers' => [
    ...Others...,
    Sukohi\FormAction\FormActionServiceProvider::class,
]

Also alias

'aliases' => [
    ...Others...,
    'FormAction' => Sukohi\FormAction\Facades\FormAction::class,
]

Preparation

First of all, execute migrate command from the package.

php artisan vendor:publish --provider="Sukohi\FormAction\FormActionServiceProvider"

Now, you have formaction.php in your config folder. So you need to set route or path there like so.

return [

    /*
     * Routes
     */
    'routes' => [
        'home.login' => 'home.authenticate'	// When current route is `home.login`, return `route('home.authenticate')`.
    ],

    /*
     * Paths
     */
    'paths' => [
        '/login' => 'auth/authenticate'	// When current path is `/login`, return `/auth/authenticate`.
    ]

];

Usage

Simple Usage

<form action="{{ FormAction::get() }}">

with Options

[Default Path]

<form action="{{ FormAction::get(['default' => '/default_path']) }}">

[Route Parameters]

<form action="{{ FormAction::get(['parameters' => [1, 2, 3]]) }}">

Using route() method

<form action="{{ FormAction::route() }}">

[with Parameters]

<form action="{{ FormAction::route(1) }}">
<form action="{{ FormAction::route([1, 2, 3]) }}">

[with Default Path]

<form action="{{ FormAction::route(1, '/default_path') }}">

Using path() method

<form action="{{ FormAction::path() }}">

[with Default Path]

<form action="{{ FormAction::path('/default_path') }}">

License

This package is licensed under the MIT License.

Copyright 2016 Sukohi Kuhoh