1. Go to this page and download the library: Download codesleeve/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/ */
use Codesleeve\Stapler\ORM\StaplerableInterface;
use Codesleeve\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);
}
}
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();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.