김정명 김정명 - 23 days ago 5
PHP Question

How can use multiple function in model Laravel

Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class mypage extends Model
{
public $rules = [
'name' => 'required',
'message' => 'required',
'password' => 'required'
];

public $edit = [
'message' => 'required'
];

protected $table = 'mypages';
}


I want to use on controller like this ,
$validator = validator::make($data = Input::all(), mypage::$edit);
,
$validator = validator::make($data = Input::all(), mypage::$rules);


but It brings error like this:FatalThrowableError in MyPageController.php line 59:
Access to undeclared static property: App\mypage::$edit

How can I use like this?

Answer

Try to use static keyword:

public static $edit = [
    'message' => 'required'
];