ActivitySubmitWork.php
765 Bytes
<?php
namespace App\Models\Views;
use App\Models\Activity;
use App\Models\TidingsHasInteract;
use App\Models\User;
use App\Support\Model;
use Illuminate\Support\Facades\Auth;
class ActivitySubmitWork extends Model
{
protected $table = 'activity_user_submits';
public function activity()
{
return $this->belongsTo(Activity::class);
}
public function like()
{
return $this->hasMany(TidingsHasInteract::class, 'type_id', 'id')->where(['type' => 4]);
}
public function isLike()
{
return $this->hasOne(TidingsHasInteract::class, 'type_id', 'id')->where(['type' => 4, 'user_id' => Auth::id()]);
}
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
}