You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
704 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
abstract class BaseModel extends Model {
protected $casts = [
'created_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'deleted_at' => 'datetime:Y-m-d H:i:s',
];
protected $dateFormat = 'Y-m-d H:i:s';
/**
* 자신의 데이터만 구하기 위함
* @param string $column
* @return bool
*/
public function checkOwner($column = "user_id") {
$user = auth()->user();
if (!$user) $user = Auth::user();
if (!$user) $user = new User;
return $this->{$column} == $user->id;
}
}