Update AvatarController

This commit is contained in:
Daniel Supernault 2019-03-01 11:54:05 -07:00
parent 5cec84f8e3
commit 0b9a5a26ad
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 2 additions and 1 deletions

View file

@ -15,6 +15,7 @@ class Avatar extends Model
* @var array
*/
protected $dates = ['deleted_at'];
protected $fillable = ['profile_id'];
public function profile()
{

View file

@ -33,7 +33,7 @@ class AvatarController extends Controller
$currentAvatar = storage_path('app/'.$profile->avatar->media_path);
$loc = $request->file('avatar')->storeAs($public, $name);
$avatar = Avatar::whereProfileId($profile->id)->firstOrFail();
$avatar = Avatar::firstOrNew(['profile_id' => $profile->id]);
$opath = $avatar->media_path;
$avatar->media_path = "$public/$name";
$avatar->thumb_path = null;