A collection of helper functions that I use across my projects.

Overview

A collection of helper functions that I use across my projects.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package includes some of the helper functions that I tend to use in all of my projects.

Installation

You can install the package via composer:

composer require ryangjchandler/laravel-helpers

Usage

user

Returns the current user, or null depending on authentication status.

This function assumes that your User model is found inside of app/Models and will not be registered if that class doesn't exist.

$user = user();

selected

Can be used to output a selected attribute conditionally.

">
<select>
    <option value="option" {{ selected($value === 'option') }}>option>
select>

You can also change the attribute that is returned. This is useful when you want to use it on checkboxes.

">
<input type="checkbox" name="remember" {{ selected($remember, 'checked') }} />

authorize

Identical to Laravel's $this->authorize() method provided by the AuthorizesRequests trait.

public function index()
{
    authorize('viewAny', Post::class);
}

url_shorten

Removes everything before :// in a URL for use as link text.

{{ url_shorten($url) }} ">
<a href="{{ $url }}">{{ url_shorten($url) }}a>

This is also available as a Str::shortenUrl method, applied via a macro.

$shortened = Str::shortenUrl($url);

Request::collect()

This behaves exactly the same as Request::all(), except it returns an instance of \Illuminate\Support\Collection.

public function store(Request $request)
{
    $collection = $request->collect();
    $pluckedCollection = $request->collect('name', 'email', 'age');
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Deploy and execute non-PHP AWS Lambda functions from your Laravel application.

Sidecar for Laravel Deploy and execute non-PHP AWS Lambda functions from your Laravel application. Read the full docs at hammerstone.dev/sidecar/docs.

Laravel basic Functions, eloquent cruds, query filters, constants

Emmanuelpcg laravel-basics Description Package with basic starter features for Laravel. Install If Builder Constants Install composer require emmanuel

webtrees module: enhanced clippings cart with more functions to add records to the clippings cart and to start actions on these records
webtrees module: enhanced clippings cart with more functions to add records to the clippings cart and to start actions on these records

webtrees module hh_clippings_cart_enhanced !!! This is an alpha version! Do not use it in a productive webtrees system! !!! This webtrees custom modul

Laravel package to work with geospatial data types and functions.

Laravel Spatial Laravel package to work with geospatial data types and functions. For now it supports only MySql Spatial Data Types and Functions. Sup

A set of useful Laravel collection macros
A set of useful Laravel collection macros

A set of useful Laravel collection macros This repository contains some useful collection macros. Spatie is a webdesign agency based in Antwerp, Belgi

Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

A collection of generators for Lumen and Laravel 5.

Lumen generators A collection of generators for Lumen and Laravel 5. Contents Why ? Installation Quick Usage Detailed Usage Model Generator Migration

Base library for repeated layout fields, content builders and other collection components

laravel-flexible-content This package's only purpose is to build custom repeated layout components, such as Laravel Nova's Flexible Content field or y

A collection of extensions for Laravel development in Visual Studio Code

Laravel Extension Pack for Visual Studio Code Includes the basic extensions to get started with Laravel development in Visual Studio Code. Laravel Ext

Releases(v0.6.0)
  • v0.6.0(Oct 16, 2022)

  • v0.5.0(May 10, 2022)

  • v0.4.0(Mar 11, 2022)

    What's Changed

    • chore: add l9 support by @ryangjchandler in https://github.com/ryangjchandler/laravel-helpers/pull/1
    • chore: remove unused macros by @ryangjchandler in https://github.com/ryangjchandler/laravel-helpers/pull/2
    • feature: attributes helper by @ryangjchandler in https://github.com/ryangjchandler/laravel-helpers/pull/3

    New Contributors

    • @ryangjchandler made their first contribution in https://github.com/ryangjchandler/laravel-helpers/pull/1

    Full Changelog: https://github.com/ryangjchandler/laravel-helpers/compare/v0.3.1...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Sep 6, 2021)

  • v0.3.0(Jul 29, 2021)

  • v0.2.0(Jul 19, 2021)

  • v0.1.1(Jul 18, 2021)

  • v0.1.0(Jul 18, 2021)

Owner
Ryan Chandler
Ryan Chandler
This package provides new helper functions that take care of handling all the translation hassle and do it for you.

Laravel Translate Message ?? This package provides new helper functions that take care of handling all the translation hassle and do it for you. Insta

Basel Rabia 17 Feb 8, 2022
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

PHPAlgorithms A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDow

Doğan Can Uçar 921 Dec 18, 2022
A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

Alert Box (Laravel) A helper package to flash a bootstrap alert to the browser via a Facade or a helper function. <div class="alert alert-info fade in

Ben-Piet O'Callaghan 17 Dec 30, 2022
Cache-purge-helper - Additional instances where nginx-helper and lscache plugin should be purged.

cache-purge-helper Additional instances where nginx-helper and lscache plugin should be purged. Install Extract the zip file. Upload them to /wp-conte

Jordan 10 Oct 5, 2022
Laravel-Mix helper for projects with complex & multi assets.

Laravel-Mix helper for projects with complex & multi assets. ?? Getting started Since mix introduced in laravel 5.4 it is recommended to use this pack

Fandogh 27 Oct 4, 2022
Collection of classes you can use to standardize data formats in your Laravel application.

Laravel Formatters This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Co

Michael Rubel 88 Dec 23, 2022
A query database collection for use with Laravel Pipeline

A query database collection for use with Laravel Pipeline This package contains a collection of class that can be used with Laravel Pipeline. Let's se

Dương Gia Bảo 188 Dec 24, 2022
A collection of easy-to-use filters with clause conditions to Filament

Filament Advanced Filter A collection of easy-to-use filters with clause conditions to Filament Installation Install the package via composer (require

Webbing Brasil 45 Jan 2, 2023
These projects are free for public use. Be a lesson for those who violate the rights of others!! ✌️

Faraz Kish Projects These projects are free for public use. Be a lesson for those who violate the rights of others!! ✌️ Brands Farazkish Uinvest MFina

Milad Shahi 30 May 20, 2022
Easy-to-use SDK for implementing Neshan APIs in your Laravel projects.

Neshan Laravel SDK Easy-to-use SDK for implementing Neshan APIs in your Laravel projects. Install The easiest way to install is by using Composer: com

null 1 Oct 22, 2022