本文整理汇总了PHP中Illuminate\Support\MessageBag::count方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageBag::count方法的具体用法?PHP MessageBag::count怎么用?PHP MessageBag::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\MessageBag
的用法示例。
在下文中一共展示了MessageBag::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleting
/**
* observe Calendar event deleting
* 1. delete child
* 2. delete chart
* 3. delete schedule
* 4. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. delete child
foreach ($model->calendars as $key => $value) {
if (!$value->delete()) {
$errors->add('Calendar', $value->getError());
}
}
//2. delete chart
foreach ($model->follows as $key => $value) {
if (!$value->delete()) {
$errors->add('Calendar', $value->getError());
}
}
//3. delete schedule
foreach ($model->schedules as $key => $value) {
if (!$value->delete()) {
$errors->add('Calendar', $value->getError());
}
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例2: saving
function saving($model)
{
$errors = new MessageBag();
///////////
// RULES //
///////////
if (is_null($model->_id)) {
$id = 0;
} else {
$id = $model->_id;
}
//////////////
// VALIDATE //
//////////////
$client = Client::key($model->key)->where('_id', '<>', $id)->first();
if ($client) {
$errors->add('Key', 'Key must be unique');
}
$client = Client::secret($model->key)->where('_id', '<>', $id)->first();
if ($client) {
$errors->add('Secret', 'Secret must be unique');
}
if ($errors->count()) {
$model->setErrors($errors);
return false;
}
}
示例3: veritranscc
/**
* Veritrans Credit Card
*
* 1. Check Order
* 2. Save Payment
*
* @return Response
*/
public function veritranscc()
{
if (!Input::has('order_id')) {
return new JSend('error', (array) Input::all(), 'Tidak ada data order id.');
}
$errors = new MessageBag();
DB::beginTransaction();
//1. Validate Sale Parameter
$order = Input::only('order_id', 'gross_amount', 'payment_type', 'masked_card', 'transaction_id');
//1a. Get original data
$sale_data = \App\Models\Sale::findorfail($order['order_id']);
//2. Save Payment
$paid_data = new \App\Models\Payment();
$payment['transaction_id'] = $sale_data['id'];
$payment['method'] = $order['payment_type'];
$payment['destination'] = 'Veritrans';
$payment['account_name'] = $order['masked_card'];
$payment['account_number'] = $order['transaction_id'];
$payment['ondate'] = \Carbon\Carbon::parse($order['transaction_time'])->format('Y-m-d H:i:s');
$payment['amount'] = $order['gross_amount'];
$paid_data = $paid_data->fill($payment);
if (!$paid_data->save()) {
$errors->add('Log', $paid_data->getError());
}
if ($errors->count()) {
DB::rollback();
return response()->json(new JSend('error', (array) Input::all(), $errors), 404);
}
DB::commit();
$final_sale = \App\Models\Sale::id($sale_data['id'])->with(['voucher', 'transactionlogs', 'user', 'transactiondetails', 'transactiondetails.varian', 'transactiondetails.varian.product', 'paidpointlogs', 'payment', 'shipment', 'shipment.address', 'shipment.courier', 'transactionextensions', 'transactionextensions.productextension'])->first()->toArray();
return response()->json(new JSend('success', (array) $final_sale), 200);
}
示例4: saving
/**
* observe policy saving
* 1. act if error or not
*
* @param $model
* @return bool
*/
public function saving($model)
{
$errors = new MessageBag();
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例5: deleting
/**
* observe user invitation log event deleting
* 1. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
$errors->add('User', 'Tidak bisa menghapus log invitation.');
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例6: deleting
/**
* observe Employee event deleting
* 1. check contract works
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. check contract works
if ($model->contractworks->count()) {
$errors->add('ContractElement', 'Tidak dapat menghapus element kontrak yang sudah / sedang dipakai dalam kontrak kerja karyawan.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例7: deleting
/**
* observe payment event deleting
* 1. check relationship with transaction
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. check relationship with transaction
if ($model->sale()->count()) {
$errors->add('Payment', 'Tidak bisa menghapus data payment yang sudah divalidasi.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例8: deleting
/**
* observe Template event deleting
* 1. check documentdetails
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. check documentdetails
if ($model->documentdetails()->count()) {
$errors->add('Template', 'Tidak dapat menghapus dokumen yang berkaitan dengan karyawan atau yang memiliki template.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例9: created
/**
* observe QuotaLog event created
* 1. Audit
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function created($model)
{
$errors = new MessageBag();
//1. audit
if ($model->voucher()->count()) {
event(new AuditStore($model, 'quota_added', 'Penambahan quota voucher ' . $model->voucher->code));
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例10: deleting
/**
* observe address event deleting
* 1. check if zipcode updated
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. check if address was destination
if ($model->shipments()->count()) {
$errors->add('Address', 'Tidak dapat menghapus alamat yang pernah digunakan dalam pengiriman.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例11: deleting
/**
* observe Workleave event deleting
* 1. check followed works
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. check followed works
if ($model->followedworks()->count()) {
$errors->add('Workleave', 'Tidak dapat menghapus data cuti yang menjadi acuan cuti karyawan. Silahkan non aktif kan data cuti yang tidak berlaku lagi.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例12: saved
/**
* observe Price event saved
* 1. Audit
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function saved($model)
{
$errors = new MessageBag();
//1. audit
if ($model->product()->count()) {
event(new AuditStore($model, 'price_changed', 'Perubahan harga ' . $model->product->name));
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例13: deleting
/**
* observe product event deleting
* 1. check varian relationship with transaction
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
/* --------------------------------DELETE VARIAN RELATIONSHIP--------------------------------------*/
//1. Check varian relationship with transaction
if ($model->transactions()->count()) {
$errors->add('varian', 'Tidak dapat menghapus produk varian yang pernah di stok &/ order.');
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例14: deleting
/**
* observe policy event deleting
* 1. validate delete
* 2. act, accept or refuse
*
* @param $model
* @return bool
*/
public function deleting($model)
{
$errors = new MessageBag();
//1. validate deleting
$validating_policy = new POO();
if (!$validating_policy->validatedeleting($model)) {
$errors->add('Policy', $validating_policy->getError());
}
if ($errors->count()) {
$model['errors'] = $errors;
return false;
}
return true;
}
示例15: validate
/**
* Validate the model instance
*
* @param array $rules Validation rules
* @param array $customMessages Custom error messages
* @param array $customAttributes Custom attributes
* @return bool
* @throws InvalidModelException
*/
public function validate(array $rules = array(), array $customMessages = array(), array $customAttributes = array())
{
if ($this->fireModelEvent('validating') === false) {
if ($this->throwOnValidation) {
throw new InvalidModelException($this);
} else {
return false;
}
}
// check for overrides, then remove any empty rules
$rules = empty($rules) ? static::$rules : $rules;
foreach ($rules as $field => $rls) {
if ($rls == '') {
unset($rules[$field]);
}
}
if (empty($rules)) {
$success = true;
} else {
$customMessages = empty($customMessages) ? static::$customMessages : $customMessages;
$customAttributes = empty($customAttributes) ? static::$customAttributes : $customAttributes;
if ($this->forceEntityHydrationFromInput || empty($this->attributes) && $this->autoHydrateEntityFromInput) {
$this->fill(Input::all());
}
$data = $this->getAttributes();
// the data under validation
// perform validation
$this->validator = static::makeValidator($data, $rules, $customMessages, $customAttributes);
$success = $this->validator->passes();
if ($success) {
// if the model is valid, unset old errors
if ($this->validationErrors === null || $this->validationErrors->count() > 0) {
$this->validationErrors = new MessageBag();
}
} else {
// otherwise set the new ones
$this->validationErrors = $this->validator->messages();
// stash the input to the current session
if (!self::$externalValidator && Input::hasSession()) {
Input::flash();
}
}
}
$this->fireModelEvent('validated', false);
if (!$success && $this->throwOnValidation) {
throw new InvalidModelException($this);
}
return $success;
}