PHP code example of bansalakhil / laravel-stapler

1. Go to this page and download the library: Download bansalakhil/laravel-stapler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bansalakhil / laravel-stapler example snippets


    'Hollogram\LaravelStapler\Providers\L4ServiceProvider'

    'Hollogram\LaravelStapler\Providers\L5ServiceProvider'

use Hollogram\Stapler\ORM\StaplerableInterface;
use Hollogram\Stapler\ORM\EloquentTrait;

class User extends Eloquent implements StaplerableInterface {
	use EloquentTrait;

	// Add the 'avatar' attachment to the fillable array so that it's mass-assignable on this model.
	protected $fillable = ['avatar', 'first_name', 'last_name'];

	public function __construct(array $attributes = array()) {
		$this->hasAttachedFile('avatar', [
			'styles' => [
				'medium' => '300x300',
				'thumb' => '100x100'
			]
		]);

		parent::__construct($attributes);
	}
}

php artisan stapler:fasten users avatar
php artisan migrate

<?= Form::open(['url' => action('UsersController@store'), 'method' => 'POST', 'files' => true]) 

public function store()
{
	// Create and save a new user, mass assigning all of the input fields (including the 'avatar' file field).
    $user = User::create(Input::all());
}

<img src="<?= $user->avatar->url() 

$user->avatar = STAPLER_NULL;
$user->save();