Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UploadPicture extends Eloquent
- {
- //use PictureTrait, UploadTrait, PublishableTrait;
- use PictureTrait;
- protected $table = 'uploads';
- protected $fillable = array(
- 'title',
- 'body',
- 'tags',
- );
- public static function getRules($upload)
- {
- if($upload == null)
- {
- return array(
- 'title' => 'required|min:10|max:100',
- 'body' => 'required',
- 'picture' => 'required|image|mimes:jpg,jpeg,png,gif|max:2500'
- );
- }
- else
- {
- return array(
- 'title' => 'required|min:10|max:100',
- 'body' => 'required',
- 'picture' => 'image|mimes:jpg,jpeg,png,gif|max:2500'
- );
- }
- }
- public static function edit($upload)
- {
- if($upload == null) {
- $upload = new UploadPicture;
- $upload->type = 'picture';
- $upload->user_id = Auth::id();
- }
- $upload->fill(Input::all());
- if(Input::hasFile('picture')) {
- $upload->uploadPicture();
- $upload->createThumbnail();
- }
- $upload->save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement