33 lines
622 B
PHP
33 lines
622 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use Illuminate\Validation\Validator;
|
|
|
|
|
|
abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepository {
|
|
|
|
public function findWithoutFail($id, $columns = ['*'])
|
|
{
|
|
try {
|
|
return $this->find($id, $columns);
|
|
} catch (Exception $e) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
public function validate($values)
|
|
{
|
|
$validator = Validator::make(
|
|
$values,
|
|
$this->model()->rules
|
|
);
|
|
|
|
if($validator->fails()) {
|
|
return $validator->messages();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|