Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

BadMethodCallException: Method [validateMatch] does not exist. #31

Closed
BeingTomGreen opened this issue Mar 19, 2013 · 1 comment
Closed

Comments

@BeingTomGreen
Copy link

I am getting this issue when calling Ardent->save() or ->validate().

Model:

<?php namespace Vendor\Package\Models;

use LaravelBook\Ardent\Ardent;

class Post extends Ardent
{
    protected $table = 'posts';

    //Ardent Values
    public $autoHydrateEntityFromInput = true;

    public static $rules = array(
        'id' => 'numeric',
        'reference'  => 'required|match:/^[a-zA-Z0-9 \/&-\(\)]+$/|between:5,70',
        'title'  => 'required|match:/^[a-zA-Z0-9 \/&-\(\)]+$/|between:5,70',
        'description' => 'required|between:5,170',
        'content' => 'required|min:20',
        'status' => 'in:1,0',
    );

    public function author()
    {
        return $this->belongsTo('Vendor\Package\Models\User', 'author_id');
    }

    public function category()
    {
        return $this->belongsTo('Vendor\Package\Models\Category', 'category_id');
    }
}

?>

Controller:

  public function update($id)
  {
    //Grab the Blog post
    $post = Post::where('id', '=', $id)->first();

    //Set the various values for the updated Blog Post
    $post->category_id = Input::get('category_id');
    $post->reference = Input::get('reference');
    $post->title = Input::get('title');
    $post->description = Input::get('description');
    $post->slug = Input::get('slug');
    $post->content = Input::get('content');
    $post->status = Input::get('status');

    //Blog Post validates and updates ok
    if ($post->save())
    {
      return Redirect::action('Vendor\Package\Controllers\AdminController@index')
        ->with('message-type', 'success')
        ->with('message-content', 'Successfully updated '. Input::get('reference') .'!')
      ;
    }
    //Blog Post failed to validate..
    else
    {
      return Redirect::action(
        'Vendor\Package\Controllers\AdminController@edit', array($id))
        ->withInput()
        ->withErrors($post->errors)
      ;
    }
  }

Any ideas?

@BeingTomGreen
Copy link
Author

My bad, some how missed the switch from 'match:pattern' to 'regex:pattern'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant