PHP code example of sukorenomw / rclient

1. Go to this page and download the library: Download sukorenomw/rclient library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sukorenomw / rclient example snippets


"    "laravel/framework": "5.0.*",
    "sukorenomw/rclient": "dev-master"
}

    Roketin\Providers\RoketinServiceProvider::class,
  

    'Roketin' => Roketin\Facades\RoketinFacade::class
  

    use Roketin;
    
    $menus = Roketin::menus()->get();
    $posts = Roketin::posts()->get();
    $products = Roketin::products()->get();
    etc..

    /*
     * Same as fetching object, but in singular form (without 's')
     * the second argument can be id or slug or etc ..
     * this is dynamic function call to Roketin Engine API
     */
    
    $home = Roketin::menu('home')->get();
    $post = Roketin::post('latest-update')->get();


    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()->where('title','like','vacation')->get();
    
    //NOTE : 
    //It doesn't need to add % if using 'like' operator


    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()
                        ->where('title','like','vacation')
                        ->orWhere('title','like','holiday')
                        ->get();
    
    //NOTE : 
    //It doesn't need to add % if using 'like' operator


    /**
     * @param $field
     * @param $operation
     * @param $value
     */

    $posts = Roketin::posts()
                        ->where('title','like','vacation')
                        ->orWhere('title','like','holiday')
                        ->where('date','>=','2016-04-10')
                        ->where('date','<=','2016-04-18')
                        ->get();
    
    //NOTE : 
    //It will result query grouping 
    // (title like vacation or title like holiday) 
    // AND 
    // (date >= 2016-04-10 and date <= 2016-04-18 )


    /*
     * sorting object before fetch
     * 
     * @param $field
     * @param $direction (optional) default is ASC
     * /

    $posts = Roketin::posts()->sortBy('created_at')->get();
    $posts = Roketin::posts()->sortBy('created_at','DESC')->get();

    /*
     * grouping object before fetch
     * 
     * @param $field
     * /

    $posts = Roketin::posts()->groupBy('created_at')->get();

    /*
     * paginate object before fetch
     * 
     * @param $size default value is 10
     * @param $page (optional)
     * /

    $posts = Roketin::posts()->paginate(10)->get();
    $posts = Roketin::posts()->paginate(10,2)->get();

    $countries = Roketin::shipping()->countries()

    $province = Roketin::shipping()->province()

    /*
     * @param $provinceid
     */

    $cities = Roketin::shipping()->province(9)->cities()

    /*
     * @param $destination = city id
     * @param $courier = JNE/TIKI/POS
     * @param $weight = item weight in KG (optional) default value 1
     * @param $origin = city id
     */

    $costs = Roketin::shipping()->cost(23, 'JNE')

    /*
     * @param array $generalData
     * @param array $customerData
     * @param array $products
     */
     
     $generalData = [
            "notes"         => "some string here",
            "is_email_only" => true,
     ];

     $customerData = [
            "first_name" => "Sukoreno",
            "last_name"  => "Mukti",
            "phone"      => "+6281910513704",
            "email"      => "[email protected]",
     ];

     $products = [
         [
             "id"         => "2623",
             "qty"        => "1",
             "sku"        => "ADVHEL001",
             "price_type" => "retail_price",
         ],
     ];                                 
    $order = Roketin::order()->create([], 'JNE')

    /*
     * @param $invoice_number
     * @param $payment_type
     * @param $total
     * @param $customer_name
     * @param $transaction_number
     * @param Image $image
     * @param null $bank_account
     * @param null $paid_date
     */
     
    //you can create image for bank transfer that 
    //showing transfer is success
    //by using Image::make()
    $img = Image::make(Input::file('image'))
    
    $payment = Roketin::order()
                ->confirm('SI16041300058', 
                          'TRANSFER', 
                          '150000', 
                          'Sukoreno Mukti', 
                          'TRX-123', 
                          $img, 
                          '0853909090')

    /*
     * @param $invoice_number
     */

    $order = Roketin::order()->void('ASD02262016')

    /*
     * @param $email
     */

    $subscribe = Roketin::subscribe('[email protected]')

    /*
     * @param $sender_name
     * @param $sender_email
     * @param $sender_phone
     * @param $message_title
     * @param $message_body
     */

    $msg = Roketin::message()
                    ->send(
                    'reno',
                    '[email protected]',
                    '123123',
                    'test mesage',
                    'hai')

    /*
     * @param $code
     * @param $voucher_type (optional), default = null
     * voucher type can be giftvoucher (voucher in 
     * exchange to money nominal) or
     * other (voucher to exchange to free product)
     * default is voucher_type is other
     */

    $check = Roketin::voucher()->check('AS123D')

    /*
     * @param $voucher_code
     * @param $voucher_type (optional) default is other
     * @param $used_by (optional) default is logged in user
     */

    $check = Roketin::voucher()->invalidate('AS123D')

    /*
     * @param $first_name
     * @param $last_name
     * @param $email
     * @param $phone
     * @param $password
     * @param $password_confirmation
     * @return user object
     */

    $user = Roketin::user()->register('first_name', 'last_name', 'email', 'phone', 'password', 'password_confirmation');

    /*
     * @param $token
     * @return true if success activation
     * @return error object if present
     */

    $activation = Roketin::user()->activate('token');

    /*
     * @param $email
     * @return true if success activation
     * @return error object if present
     */

    $resend = Roketin::user()->resendActivation('[email protected]');

    /*
     * @param $email
     * @return true if success activation
     * @return error object if present
     */

    Roketin::user()->forgot('[email protected]');

    /*
     * @param $token
     * @param $password
     * @param $password_confirmation
     * @return true if success activation
     * @return error object if present
     */

    Roketin::user()->resetPassword('token','asdf','asdf');

    /*
     * @param $email
     * @param $password
     * @param $type (optional) default = user, available = vendor
     * @return true if success activation
     * @return error object if present
     */

    Roketin::auth()->login('[email protected]','asdf');

    /*
     * @return user object
     */

    Roketin::auth()->user();

    /*
     * @return user object
     */

    Roketin::user()->update(['first_name' => 'John']);

    /*
     * @return user object
     */

    Roketin::user()->transactionHistory()->get();

    /*
     * @return boolean
     */

    Roketin::auth()->logout();