All Projects → pyaesone17 → active-state

pyaesone17 / active-state

Licence: MIT License
Laravel Active State Url Helper For Request

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to active-state

laravel-ui-stisla
Laravel UI Frontend Preset for Stisla with Laravel Fortify support.
Stars: ✭ 46 (+2.22%)
Mutual labels:  laravel-package
email-checker
Provides email verification on the go.
Stars: ✭ 116 (+157.78%)
Mutual labels:  laravel-package
devtube
Laravel YouTube and Online Video viewing and download interface.
Stars: ✭ 30 (-33.33%)
Mutual labels:  laravel-package
laratify
Laravel UI Components using TailwindCSS & AlpineJS
Stars: ✭ 13 (-71.11%)
Mutual labels:  laravel-package
nova-url-field
A URL input and link field for Laravel Nova
Stars: ✭ 96 (+113.33%)
Mutual labels:  laravel-package
artisan-cloudflare
Laravel artisan commands for CloudFlare
Stars: ✭ 67 (+48.89%)
Mutual labels:  laravel-package
cj-temporal-models
No description or website provided.
Stars: ✭ 29 (-35.56%)
Mutual labels:  laravel-package
phpcsfixer-preset
Use the same php-cs-fixer configuration across all of your projects, with presets for common project layouts (Laravel, Composer packages, etc.).
Stars: ✭ 22 (-51.11%)
Mutual labels:  laravel-package
track-who
Laravel Traits for tracking who's done what to your models
Stars: ✭ 29 (-35.56%)
Mutual labels:  laravel-package
maintenance-mode
An enhanced maintenance mode for Laravel.
Stars: ✭ 117 (+160%)
Mutual labels:  laravel-package
artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (+24.44%)
Mutual labels:  laravel-package
hms-safetydetect-demo-android
SafetyDetect Sample provides many sample programs for your reference or usage.This example demonstrates how to integrate services provided by Safetydetect Kit, such as APPchecks, URLcheck, Userdetect, Wifidetect.
Stars: ✭ 16 (-64.44%)
Mutual labels:  url-check
panichd
Ticketing system for Laravel 5.1 - 8.x. Allows to create new tickets via form only. Includes file attachments, ticket tags, filtering, scheduling and e-mail notifications.
Stars: ✭ 78 (+73.33%)
Mutual labels:  laravel-package
laravel-repoman
Set a payment deadline for the customer
Stars: ✭ 14 (-68.89%)
Mutual labels:  laravel-package
dropzoner
Laravel package for image upload using DropzoneJS
Stars: ✭ 46 (+2.22%)
Mutual labels:  laravel-package
laravel-easyblade
Create an easier & readable Blade (view) in Laravel with EasyBlade
Stars: ✭ 64 (+42.22%)
Mutual labels:  laravel-package
Laravel-Unsplash-Wrapper
A Laravel wrapper for Unsplash API's.
Stars: ✭ 21 (-53.33%)
Mutual labels:  laravel-package
laravel-bitcoinrpc
Bitcoin JSON-RPC Service Provider for Laravel.
Stars: ✭ 83 (+84.44%)
Mutual labels:  laravel-package
smart-schema
A Laravel package to enable auto generation of forms
Stars: ✭ 18 (-60%)
Mutual labels:  laravel-package
laravel-miniprogram-poster
Use Laravel to building a miniprogram poster.
Stars: ✭ 72 (+60%)
Mutual labels:  laravel-package

Active State

Total Downloads License Latest Stable Version Monthly Downloads

Simple Laravel Active Checker For Request Url

Sometimes you want to check the request url is active or not For the following purpose. Especially for backend sidebar.

Bilby Stampede

Basically we do like this.

<li class="sidebar {{ Request::is('post') ? 'active' : 'no' }} ">Post</li>
<li class="sidebar {{ Request::is('page') ? 'active' : 'no' }} ">Page</li>

It would be nice if we can make shorter. right ?

<li class="sidebar {{ active_check('post') }} ">Post</li>
<li class="sidebar {{ active_check('page') }} ">Page</li>

Installation

Install with composer:

Laravel 5.4 and above

composer require pyaesone17/active-state:^1.1.1

Laravel 5.3 and below

composer require pyaesone17/active-state:^0.0.2

And add the service provider in config/app.php

'providers' => [
    ........,
    Pyaesone17\ActiveState\ActiveStateServiceProvider::class,
]

If you want to use the facade, add this to your facades in config/app.php

'aliases' => [
    ........,
    'Active' => Pyaesone17\ActiveState\ActiveFacade::class,
]

To publish configuration file

php artisan vendor:publish --provider="Pyaesone17\ActiveState\ActiveStateServiceProvider"

Usage

It will check against whether your request is www.url.com/data If the request match this url . It will return the default value from config file. The default value for true state is "active" and false is "no". You can configure on active.php .

{{ Active::check('data') }} 

To check the exact url.

{{ Active::check('data') }} // check request is www.url.com/data

To check the url deeply , just pass the true value as second parameter.

{{ Active::check('data',true) }}  // check request is www.url.com/data || www.url.com/data/*

OR

{{ Active::check(['data','post','categories']) }}  // check request is www.url.com/data || www.url.com/post || www.url.com/categories
{{ Active::check(['data','post','categories'],true) }} // check request is www.url.com/data/* || // check request is www.url.com/post/* || www.url.com/categories/*

To change the return value in runtime, just pass the the third and fourth parameter.

{{ Active::check('data',true,'truth','fake') }} // it will override the value from config file.

Or you can even use helper function.

{{ active_check('data') }}

You can also use this package for conditional displaying data. In some case, You need to render some part of template depends on request.

@ifActiveUrl('data')
    <p>Foo</p>
@else
    <p>Bar and Bazz</p>
@endIfActiveUrl

Advance Usage and Above version 1.1.1

To check the route name is.

{{ Active::checkRoute('users.index') }} // check request url route name is "users.index"

OR

{{ Active::checkRoute(['users.index','users.show', 'users.edit']) }} // check request url route name is "users.index" or "users.show" or "users.edit"

Sometimes passing multiple routename as parameters is cubersome. You can simple do like this

{{ Active::checkRoute('users.*') }} 

Ofcousre you may change the return value in runtime as second and third params.

{{ Active::checkRoute('users.index','routeIsActive','routeNotActive') }} 

OR

{{ Active::checkRoute(['users.index','users.show'],'routeIsActive','routeNotActive') }} 

For helper function.

{{ active_route('users.comments.*') }} 

Yes it is also avaialable in blade.

@ifActiveRoute('users.index')
    <p>Foo</p>
@else
    <p>Bar and Bazz</p>
@endIfActiveRoute

To check the url with the exact same query paramter value.

{{ Active::checkQuery('users?gender=male') }} // check request is www.url.com/users?gender=male

OR

{{ Active::checkQuery(['users?gender=male','users?status=married']) }} // check request is www.url.com/users?gender=male or www.url.com/users?status=married

Ofcousre you may change the return value in runtime as second and third params.

{{ Active::checkQuery(['users?gender=male','itIsMale','Ah it is wonder woman') }} 

OR

{{ Active::checkQuery(['users?gender=male','users?status=married'],'male or married','nothing') }} 

For helper function.

{{ active_query('users?gender=male') }} 

Yes it is also avaialable in blade.

@ifActiveQuery(['users?gender=male','users?status=married'])
    <p>Foo</p>
@else
    <p>Bar and Bazz</p>
@endIfActiveQuery

Notes

Everytime u update package, you have to run "php artisan view:clear" for blade directives.

Configuration

You can configure the return value of active state.

return [

    // The default  value if the request match given action
    'active_state'      =>  'active',

    // The default  value if the request match given action
    'inactive_state'    =>  'no'

];
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].