Saturday, May 30, 2020

New product - Android mobile app for uBusinessDirectory released


We're happy to announce that Android mobile app for uBusinessDirectory has been released.
Almost everyone nowadays wants a mobile version of their website. Using our mobile appointment app will help your business to increase the revenue of business directory with ease. This is a truly hybrid mobile application for your business directory website, where you can reach your clients in real-time.
  • All the data will be displayed realtime.
  • Search listings and contact them on the go.
  • Works with businesses, private persons and other
Clients could download mobile app, install it and look for business listings directly form their mobile or tablet devices.
We also suggest a custom solution for your business, where you can change the logo of your company and other elements of the template and app.
Find more information here.

Saturday, May 16, 2020

New version 2.3.4 of uBusinessDirectory is released

New version 2.3.4 of uBusinessDirectory script has been released. uBusinessDirectory is one of the best one-size-fits-all solutions for creating Business Directory classified websites. This script allows to add categories, then associate added businesses to these categories. We provide you all things you need for a successful website such as: listings management, search engine friendly URLs, database backup, advanced text editor, banner rotation system etc. So it is really easy to start your own successful directory website. Listing owner has a complete control on listings in a real-time. See full list of changes here.

Wednesday, April 08, 2020

Laravel 6 - Creating Custom Form Request Validation


There is few ways to validate form submission data in Laravel.

The standard way is to use Validator facade in the beginning of your controller.
Lets see the example:

/**
 * Store a newly created resource in storage.
 *
 * @param \Illuminate\Http\Request $request
 *
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
  $validator = Validator::make($request->all(), [
    'title'  => 'required|min:5|max:200',
    'body_content'=> 'required|min:10',
    'blog_tag_id' => 'nullable',
  ],[
    'title.required' => trans('blog::alert.danger.reason.title_required'),
    'title.min'     => trans('blog::alert.danger.reason.title_min'),
    'title.max'      => trans('blog::alert.danger.reason.title_max'),
    'body_content.required' => trans('blog::alert.danger.reason.content_required'),
    'body_content.min' => trans('blog::alert.danger.reason.content_min'),
  ]);

  // ... next part of code after validation
}

In this example we perform validation inside the controller's action. It looks nice enough until you want to use the same code in another places: when you create a post in Backend or if you want to add a Unit tests. In such cases, you will copy-paste the same pieces of your code, that is not good, because you have to support all of them and such style of programming breaks DRY principle (Don't Repeat Yourself).

So... what the better way to implement such validation?
Laravel allows us to create our own Request class, instead of using a standard \Illuminate\Http\Request and use as a function parameter.

The first thing you have to do it to create such class.
Run following command:
$ php artisan make:request App\\Http\\Requests\\MyOwnRequest

This command will create MyOwnRequest request class in App\Http\Requests\ directory.
By default it will be looked as follow:


namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        ];
    }
}

Now you may move here your validation rules and replace Request parameter in store method with MyOwnRequest:

Your controller store method will be looking:

/**
 * Store a newly created resource in storage.
 *
 * @param \Illuminate\Http\MyOwnRequest $request
 *
 * @return \Illuminate\Http\Response
 */
public function store(MyOwnRequest $request)
{
 
  // ... next part of code after validation
}


MyOwnRequest class will be looking:
Remember to turn return value of authorize() method to TRUE!

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'title'  => 'required|min:5|max:200',
           'body_content'=> 'required|min:10',
           'blog_tag_id' => 'nullable',
        ];
    }
}

Looks much better, right? But what if you want to specify custom validate messages?
It's easy to implement with messages() method of your validator class. You simple have to define an array, where the key is a field name and the value is the custom message you want to show.
Let's see how to do this:


namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class MyOwnRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'title'  => 'required|min:5|max:200',
           'body_content'=> 'required|min:10',
           'blog_tag_id' => 'nullable',
        ];
    }

    /**
     * Custom message for validation
     *
     * @return array
     */
    public function messages()
    {
        return [
         'title.required' => trans('blog::alert.danger.reason.title_required'),
         'title.min'     => trans('blog::alert.danger.reason.title_min'),
         'title.max'      => trans('blog::alert.danger.reason.title_max'),
         'body_content.required' => trans('blog::alert.danger.reason.content_required'),
         'body_content.min' => trans('blog::alert.danger.reason.content_min'),
        ];
    }
}

Ok, good. But what to do if you need to validate a set of fields, lets say: few checkboxes or few file fields? In this case you may use asterisk * to prepare validation rules. Check below how we define validation rules for set of fields. I hope it's clear and understandably enough.
public function rules(): array
{
   return [
      'files.*' => 'required|image|mimes:jpg,jpeg,png',
      'attrs.*.from' => 'nullable|numeric',
      'attrs.*.to' => 'nullable|numeric',
   ];
}

Laravel creates validation messages automatically, so sometimes you will need to provide a special names to your fields. You may use the following language lines are used to swap attribute place-holders with something more reader friendly such as E-Mail Address instead of "email" or indexes in array. This simply helps us make messages a little cleaner.
public function attributes(): array
{
   return [
      'receivers' => 'Nice name',
      'subject' => 'Like name',
      'body' => 'Another Name',
      'notify.blog.*' => 'Blog Notification value',
   ];
}



Friday, April 03, 2020

Discount 40% Off! - Special 2020 Huge Spring Sale for ApPHP Members


Hi, everyone, here 2020 Huge Spring Sale!
Enjoy with a 40% Offer till 30 April 2020 ONLY!

Coupon Code: 2020-53DL-VZTH-UDR1


Enter this coupon code on checkout page and discount will be automatically applied to your order.



Valid on:
https://apphp.com
http://hotel-booking-script.com
http://business-directory-script.com

http://auto-dealers-script.com 
http://doctor-appointment-script.com
http://bid-auction-script.com 

Saturday, February 22, 2020

New version 1.3.2 of ApPHP MVC Framework is released

A new version 1.3.2 of ApPHP MVC Framework was released.

ApPHP MVC Framework is designed to provide modern and rapid development of websites, web applications and web services. It implements the the Model-View-Controller (MVC) design pattern and principles, including separation of display, logic, and data layers.

It provides an architecture, components and tools for developers to build a complex web applications faster and safer.

There are many changes and improvements in new version, including PHPUnit tests, new methods in CActiveRecord, CHttpRequest, etc. You can review all recent changes here.

Tuesday, January 14, 2020

New version 4.2.5 of ApPHP Shopping Cart is released

New version 4.2.5 of ApPHP Shopping Cart has been released and available now for downloading. This absolutely new script, based on ApPHP MVC Framework with many improvements and new features, like: adding to favorites, adding to comparison, new custom fields for products: color, weight, dimensions etc. All recent changes can be viewed here.

The script provides all necessary features including multi-currency and multi-language support. Visitors may view the contents of their shopping cart at any time and may add or delete items as needed. The program automatically calculates the subtotal, shipping charges, and total price. When a visitor decides to checkout, the order information is collected in database a receipt is sent to the shopper.

Last changes:
  • New added tabs & tags for products
  • New added manufacturer page with link to it from product description page
  • New added two types of gallery on product page
  • New added possibility to show/hide prices on Frontend
  • New added possibility to show/hide Add to Cart button on Frontend
  • New added possibility to show category images on Frontend
  • New added possibility to select product options from product description page
  • New added possibility to show images for product options
  • New added category description on category page on Frontend
  • New added possibility to add to cart the same product with different options
  • New added success payment page
  • New added order comments
  • New added is default field for the delivery settings
  • New ApPHP Framework updated to v1.2.2
  • New ApPHP Directy CMF updated to v3.0.2
  • New improved tags for products
  • New improved work of options
  • New added more information in the payment.log file for PayPal
  • New updated method of processing statuses for PayPal
  • New show country and state in the invoice
  • Fix bugs fixed
See Live Demo