Skip to content

johnjjung/support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support

Author Github Release Packagist Packagist

This is a Laravel based package that I have created for code to be easily reused for tedious tasks in creating an application.

Installation

$ composer require iolson/support

And then include the service provider within your app/config/app.php.

'providers' => [
	IanOlson\Support\Providers\SupportServiceProvider::class,
],

If you would like to have Meta Data for your models, be sure to publish the vendor files:

$ php artisan vendor:publish

Usage

Here is basic usage of Traits that are included in this package.

SeoTrait

--

This trait uses SEOTools Package, which will need to be setup if you want to use this trait inside your project. You can see install instructions below.

Documentation coming soon.

UpdateTrait

--

Add the trait as a use entry on your repository. This will pull in some new methods in order to create/update records.

/**
 * Update model attributes from a request.
 *
 * @param       $model
 * @param array $data
 *
 * @return bool
 */
protected function updateAttributes(&$model, array &$data)
{
    if (empty($data)) {
        return false;
    }

    // Get mass assignment columns of the model.
    $massAssign = $model->getFillable();

    foreach ($data as $attribute => $value) {

        if (!in_array($attribute, $massAssign)) {
            continue;
        }

        $model->$attribute = $value;
    }

    return true;
}

UploadTrait

--

Documentation coming soon.

ValidateTrait

--

Add the trait as a use entry on your repository. This will pull in the Laravel validation method. Before you call the validation method, you will setup the rules that will need to validate the request by using the following. $data is a passed in data of $request->all() from a controller.

/**
 * {@inheritDoc}
 */
public function create(array $data)
{
    // Setup validation rules.
    $this->rules = [
        //
    ];

    // Run validation.
    $this->validate($data);
    
    ...
}

Third-Party Package Usage

This package pulls in other packages, here is a quick how-to guide taken from each of the respective GitHub pages and also a link to their packages for further information on usage.

Laravel Debugbar (GitHub)

--

Include the service provider within your app/config/app.php.

'providers' => [
	Barryvdh\Debugbar\ServiceProvider::class,,
],

Intervention Image (GitHub)

--

Include the service provider within your app/config/app.php.

'providers' => [
	Intervention\Image\ImageServiceProvider::class,,
],

Include the facade within your app/config/app.php.

'aliases' = [
	'Image' => Intervention\Image\Facades\Image::class,
],

Searchable (GitHub)

--

Add the trait to your model and your search rules.

use Nicolaslopezj\Searchable\SearchableTrait;

class User extends \Eloquent
{
    use SearchableTrait;

    /**
     * Searchable rules.
     *
     * @var array
     */
    protected $searchable = [
        'columns' => [
            'first_name' => 10,
            'last_name' => 10,
            'bio' => 2,
            'email' => 5,
            'posts.title' => 2,
            'posts.body' => 1,
        ],
        'joins' => [
            'posts' => ['users.id','posts.user_id'],
        ],
    ];

    public function posts()
    {
        return $this->hasMany('Post');
    }

}

Now you can search your model.

// Simple search
$users = User::search($query)->get();

// Search and get relations
// It will not get the relations if you don't do this
$users = User::search($query)
            ->with('posts')
            ->get();

SEOTools (GitHub | English Readme)

--

Include the service provider within your app/config/app.php.

'providers' => [
	Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class,,
],

Include the facade within your app/config/app.php.

'aliases' = [
	'SEO' => Artesaos\SEOTools\Facades\SEOTools::class,
],
$ php artisan vendor:publish

You will need to edit the default config that gets published which will be located at app/config/seotools.php. Under the defaults there is a default SEO tags that will get appended to the ones that you setup.

Add the following in your views file {!! SEO::generate() !!}. Here is an example.

<html>
	<head>
		{!! SEO::generate() !!}
	</head>
	<body>
	</body>
</html>

Support

The following support channels can be used for contact.

Bug reports, feature requests, and pull requests can be submitted following our Contribution Guide.

Contributing & Protocols

Roadmap

Will be adding anything that I keep using on a consistent basis to this package so I'm not rewriting things all the time.

License

This software is released under the MIT License.

© 2015 Ian Olson, All rights reserved.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages