Crazylife

Crazylife

Member Since 1 Year Ago

Experience Points 9,300
Experience Level 2

700 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 2
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

17 May
2 days ago

Crazylife started a new conversation (500) Internal Server Error Ipay88 Payment Gateway Integration

I have set the backendURL to https://testing.com/backend_response

using POST method for my (backend_response) route.

BackendURL need to return with the Response Data as "200" and the Response Data as "RECEIVEOK" to acknowledge that the payment status has been received.

In my controller, i already did as below


public function test() {
// some staatus code here
  return response()->setStatusCode(200, "RECEIVEOK");
}

May i know is this they way to return the response to the ipay88?

16 May
3 days ago

Crazylife left a reply on Laravel Csrf Token Mismatch In POST Request With URL

@PHPHUPPTECHNOLOGIES - Thanks for the reply, I already figured it and working fine !

15 May
4 days ago

Crazylife left a reply on Laravel Csrf Token Mismatch In POST Request With URL

@TOKOIWESLEY - I tried to exclude using your way

protected $except = [
        'response',
    ];

But still return me token mismatch, will it affected if any prefix in front of the response? E.g. www.test.com/my/response

Crazylife left a reply on Laravel Csrf Token Mismatch In POST Request With URL

@TOKOIWESLEY - I can't use blade, because i set the url for payment gateway response.

Crazylife started a new conversation Laravel Csrf Token Mismatch In POST Request With URL

I am getting token mismatch when i call to a url www.test.com/response

In my web.php

  Route::post("response", '[email protected]');

I am getting token mismatch because i didnt pass any crsf_token to it. How to solve this issue?

24 Apr
3 weeks ago

Crazylife started a new conversation Ipay88 Payment Gateway Integration

Anyone had tried integrate ipay88 payment gateway? Is there any package can be used like paypal?

23 Apr
3 weeks ago

Crazylife started a new conversation How Do E-commerce Orders Process Work When Checkout?

May i know is the purchase order being created when customer clicked on checkout before payment made? The created purchase order payment status will be set to unpaid and pending the payment. And also the purchase order will be cancelled after a certain period if status still remain unpaid.

Is this how it works for e-commerce?

21 Apr
4 weeks ago

Crazylife started a new conversation How To Limit The Link Of Pagination To Be Displayed?

I want to show less page link for the pagination, by default it looks like

< 1 2 3 4 5 6 7 8 ... 100 101 >
< 1 2 ... 8 9 10 11 12 13 14 ... 100 101 >

How can i make it in this way?

< 1 2 3 4 5 ... 101 >
< 1 ... 8 9 10 11 ...101 >

This is my code

@if ($paginator->hasPages())
    <ul class="pagination">
        {{-- Previous Page Link --}}
        @if ($paginator->onFirstPage())
            <li class="page-item disabled"><span class="page-link">&laquo;</span></li>
        @else
            <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li>
        @endif

        {{-- Pagination Elements --}}
        @foreach ($elements as $element)
            {{-- "Three Dots" Separator --}}
            @if (is_string($element))
                <li class="page-item disabled"><span class="page-link">{{ $element }}</span></li>
            @endif

            {{-- Array Of Links --}}
            @if (is_array($element))
                @foreach ($element as $page => $url)
                    @if ($page == $paginator->currentPage())
                        <li class="page-item active"><span class="page-link">{{ $page }}</span></li>
                    @else
                        <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
                    @endif
                @endforeach
            @endif
        @endforeach

        {{-- Next Page Link --}}
        @if ($paginator->hasMorePages())
            <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>
        @else
            <li class="page-item disabled"><span class="page-link">&raquo;</span></li>
        @endif
    </ul>
@endif

How can i achieve the desired output as i stated? Thanks.

19 Apr
1 month ago
18 Apr
1 month ago

Crazylife started a new conversation How To Set Persistent Database Connection For Different User From Different Country Login?

I have tried to use middleware, e.g.

 $country  = $request->route()->parameter('country');

        DB::disconnect();
        Config::set('database.default','test_'.$country);
        DB::reconnect();

//my route
Route::group([
    'prefix' => '{country}',
    'middleware' => 'locale'
], function() {
.....
  Route::group(['prefix' => 'user'], function () {
Auth::route();
......
    });
    });

It works for register and login, but failed for others like view user account...etc.

May i know what's wrong with this?

I am trying to set up 1 database for 1 country. Should i just set it in app service provider using request::segment and config set my database?

10 Apr
1 month ago

Crazylife started a new conversation Best Practice Url And Route Design For Multilingual Website Using Subfolder Instead Of Sub Domain

I have a question about when design a multi language and country website url.

I am using subfolder inside my main folder instead of subdomain when implement the system. In my system, i allow them to select language and the country site.

For example, if i am select english as my language and a country then the url as belows

/subfolder/en/country_code/index

My route looks like

Route::group(['prefix' => 'test/{language}/{county_code}'], function () {
  
});

Should i open multiple subfolder for each country? Or i can maintain one subfolder and connect to multiple database based on country?

Any advice on doing this? Thanks.

21 Feb
2 months ago

Crazylife started a new conversation How To Get Record In Between Range Of Quantity?

I have records as shown below

    id | min | max
    1       5   15
    2       15  null

For example, my query

$test = test::where('max' , '>=', 10)->where('min' , '<=', 10)->get();

This result return me null collection.

The 'max' null as infinity. How can i make it like if i put 10 then it will return result id = 1 for me. if put 16 then will return id = 2?

17 Feb
3 months ago

Crazylife left a reply on Unit Converter For Product

@SNAPEY - ya, right. Do i need attribute like parent id to know which is the biggest and smallest unit? E.g. Carton -> Box -> pcs

Crazylife left a reply on Unit Converter For Product

@SNAPEY - Because i am storing only conversion rate to base. But i didnt store conversion between box and carton. I only know carton = how many pcs and box = how many pcs

Crazylife left a reply on Unit Converter For Product

@SNAPEY - For example, pcs is always my base unit for conversion. But during display, will show 1carton = 10box = 100pcs

Crazylife started a new conversation Unit Converter For Product

I have a question regarding to unit converter for product. I stored the following data as shown below

1 PCS  = 1 PCS
1 BOX = 10 PCS
1 CARTON = 40 PCS

database design

id | fromUnit | ratio | toUnit

How should i design my database so that i know 1 BOX = ? CARTON? E.g 2 BOX = 0.5 CARTON. (Formula : 20/40 = 0.5)

15 Feb
3 months ago

Crazylife left a reply on Suggestion On Database Design For Storing Product With Bulk Purchase Price

@ARTCORE - Not sure if i am getting it right. Based on the table(product_bulk_price) i created, it serves as a condition rule table, just make some changes on it.

E.g.

Product_bulk_price (product_discount)
----------------------------
id_price    | id_product    | min_qty   | max_qty   | price_type        | price
1           1           20          null            discount        10      

if quantity && discount is a rule, then i will apply 10% on the retail unit price.

Instead of storing the unit price in same table with the rule, but create a discount table to store the condition rule.

Sorry, if i am getting it wrong. Just first time implement this, need take time to go through. hehe

Crazylife left a reply on Suggestion On Database Design For Storing Product With Bulk Purchase Price

@ARTCORE - Mind to show some sample? I am having some price like retail price (applied while less than qty rule purchased) and wholesale price (applied when reached certain qty purchased).

Crazylife started a new conversation Best Database Design For Storing Product With Multiple Price

I am designing a database which able to store multiple price for each product. Is there any flaw for the design below?

Product
-----------
id_product| name            | uom | active | ...
1                 | product A     | bag  | 1          |...

Product_bulk_price
----------------------------
id_price  | id_product  | min_qty    | max_qty           | unit_price
1              | 1                   |10              | 29                       | 10
2              | 1                   | 30             | null                     | 8
....so on

My case want to store multiple price of the product. Each product will be given different price when hit the quantity as stated. If qty fall 10-29 then price = 10, else 30 or more price = 8.

I will do calculation based on user order quantity and sum it.

Is there any better solution or any suggestion? Am i on the right track?

30 Jan
3 months ago

Crazylife left a reply on Extends Blade File From Layouts Directory Caused Syntax Error

@MANELGAVALDA - Sorry, i found the error because of missing ' while extends haha.

Crazylife started a new conversation Extends Blade File From Layouts Directory Caused Syntax Error

I have 2 blade file in my layouts directory

-master.blade.php
-page.blade.php

My page.blade.php will extends master.

In my pages directory, i created an index page, and then extends to layouts.page. When i run it it throws me synxtax error.

syntax error, unexpected '__data' (T_STRING)

When i removed the extends in page.blade.php. Then it works. Anything wrong with it?

17 Dec
5 months ago

Crazylife left a reply on How To Bcc To Sender Mail?

@SIANGBOON - i am using this way

 $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl');
            $transport->setUsername('[email protected]');
            $transport->setPassword('123456');
            $gmail = new Swift_Mailer($transport);
            Mail::setSwiftMailer($gmail);

Mail::send('emails.user.registered', function($m) use ($email, $subject) {
                $m->to($email)
                  ->bcc('[email protected]','System Mailer')
                  ->subject($subject)
            });

I am doing it in this way, but not working.

16 Dec
5 months ago

Crazylife left a reply on How To Bcc To Sender Mail?

@SIANGBOON - Let's say, i am using [email protected] as my sender, i sent to [email protected] and bcc back to [email protected] It is not working when sender and bcc same email address.

Crazylife started a new conversation How To Bcc To Sender Mail?

I tried to keep a copy of mail content by bcc to sender mail but it doesn't work. Is there a way to keep a copy to what sender sent?

25 Oct
6 months ago

Crazylife left a reply on Calculation For Stock Expiry Date

@Vilfago if using your way, i think need to add some other calculation to get the difference day, am i right? When manufacture_date = 2018-10-21, shelf life = 7 then my expiry date will be 2018-10-27. If today date 2018-10-25, follow your method it will return 1 day. By right, the difference should be 2 days? Correct me if i am wrong.

Crazylife left a reply on Calculation For Stock Expiry Date

@Vilfago Yes, but this will return positive all the time, i want to detect whether it is expired or not instead of just different of day.

24 Oct
6 months ago

Crazylife started a new conversation Calculation For Stock Expiration Date

Check Product A expiry date:

$manufacturer_date = "2018-10-21";
$expiry_day =  7;
$expiry_date = Carbon::parse($manufacturer_date)->addDays(($expiry_day - 1))->format('Y-m-d'); // 2018-10-27

Here i calculate the difference between expiry date and today date.

// expiry date - today date
$today = strtotime(Carbon::now()->format('Y-m-d'));
$expiry = strtotime(expiry_date);
$diff_day = (int)floor(($expiry-$today)/(60*60*24));

if day difference less than zero meaning all considered as expired. Am i doing in correct way for calculation?

17 Oct
7 months ago

Crazylife left a reply on Is There Possible To Make A File Import All Class Model, And Then Share It To Multiple Controller?

Just curious, because keep declaring same class over the other controller, will left out sometime. So want to make it like global, so i can just use it everywhere.

Crazylife started a new conversation Is There Possible To Make A File Import All Class Model, And Then Share It To Multiple Controller?

I want to make this to global which can share among controller/

use App\Models\ModelName;

Possible to do it or every controller can only has its own imports/aliases?

03 Oct
7 months ago

Crazylife started a new conversation How To Convert Date To Timezone?

I want to convert my created_at date, i do something like this but got error

 Model::whereDate(DB::raw("(CONVERT_TZ(created_at, +5:00, +8:00))"), '=>', $start)->whereDate(DB::raw("(CONVERT_TZ(created_at, +5:00, +8:00))"), '<=', $end)......
        

I tried but i gave me error, is there anyway can convert timezone using eloquent model?

10 Sep
8 months ago

Crazylife left a reply on How To Create From Format With Timezone Using Carbon?

@pardeepkumar I am getting the file format from integration, they will pass me a format like GMT+8 or GMT+0800, how can i store the datetime in my database?

Crazylife started a new conversation How To Create From Format With Timezone Using Carbon?

I have a string

$string = "180711000000GMT+0800"

// try to convert it 
Carbon::createFromFormat('YmdHisTO', $string)->format...

It shows me this error.

Unexpected data found.
The timezone could not be found in the database
Data missing

How can i convert the datetime if there's GMT+0800 behind of the string?

20 Aug
8 months ago

Crazylife started a new conversation How To Set Sidebar Menu To Restrict Other Role User To See The Sidebar Menu?

I am using jeroennoten/Laravel-AdminLTE. In adminlte.php, i create a menu

        [
                    'text' => 'Testing',
                    'url' => 'test',
                    'icon' => 'store',             
                    'can' => 'testing',
                ],

I have created middleware named 'testing', but it doesn't work, not appear on the side menu bar. Anything i am doing wrong?

09 Aug
9 months ago

Crazylife started a new conversation How To Use Other Font Awesome In Jeroennoten/Laravel-AdminLTE Package?

I am using font awesome version 4.7, but i found there's some other icon available in font awesome version 5.2. How can i call the font awesome version 5.2 and use it in my /config/adminlte.php? Is there any solution?

01 Aug
9 months ago

Crazylife started a new conversation How To Read Content Of Sftp Text File Line By Line And Save Into Database?

I get the file content using through the server

Storage::disk('sftp')->get($k);

ps: $k is the path of the txt file in server.

This will return

No.|Desc|Qty|
1|abc|1|
2|efg|2|
3|hhh|3|

How can i read this content line by line and save to database?

Crazylife left a reply on How To Cut All The File From A Directory From Sftp Server To Local Server Using File System?

@lostdreamer_nl Meaan that after loop and save the folder and then just call delete() function to delete related file right?

Crazylife started a new conversation How To Cut All The File From A Directory From Sftp Server To Local Server Using File System?

I have a server used to store exchange file.

/uploads/a.txt
/uploads/b.txt
....so on

I am using this to get all of the file inside /uploads/ dir.

  $list = Storage::disk('sftp')->allfiles();

After that, i use foreach to loop every file based on directory to my local.

 Storage::disk('save')->put($old,$new);

Right now i only able to save the file to local without cleaning the /uploads/ dir, and not sure is this practical way to do it. Can i know how can i cut all the file from the sftp /uploads/ dir and store to my local?

27 Jul
9 months ago

Crazylife left a reply on How To Translate Language Of Apps Based On Json Language File?

@bobbybouwmann i got this problem after using double _

Call to undefined function __()
26 Jul
9 months ago

Crazylife started a new conversation How To Translate Language Of Apps Based On Json Language File?

I have a json file consist of this data

{
  "_comment": "https://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/English.json",
  "sEmptyTable":     "No data available in table",
  "sInfo":           "Showing _START_ to _END_ of _TOTAL_ entries",
  "sInfoEmpty":      "Showing 0 to 0 of 0 entries",
  "sInfoFiltered":   "(filtered from _MAX_ total entries)",
  "sInfoPostFix":    "",
  "sInfoThousands":  ",",
  "sLengthMenu":     "Show _MENU_ entries",
  "sLoadingRecords": "Loading...",
  "sProcessing":     "Processing...",
  "sSearch":         "Search:",
  "sZeroRecords":    "No matching records found",
  "oPaginate": {
    "sFirst":    "First",
    "sLast":     "Last",
    "sNext":     "Next",
    "sPrevious": "Previous"
  },
  "oAria": {
    "sSortAscending":  ": activate to sort column ascending",
    "sSortDescending": ": activate to sort column descending"
  }
}

I tried with

trans('datatable.sInfo')
_('datatable.sInfo')

but it returns datatable.sInfo for me. What's wrong or i can only translate this with array not json?

14 Jul
10 months ago

Crazylife left a reply on How To Set Locale Based On The Language Stored In Database?

@lostdreamer_nl I created a class in middleware folder as setLocale.php, and added the class to web in kernel.php. But i can't get the user id. I am not using any session, is there anything i missing that caused the Auth::user() returning null?

Crazylife left a reply on How Can I Get The The Url Of File Inside The Resources Folder?

@lostdreamer_nl The only way to access resources folder is write a route function to get whatever i need right?

Crazylife started a new conversation How Can I Get The The Url Of File Inside The Resources Folder?

I want to get the file inside the resources folder, how can i get it?

i tried asset(), but it keeps show me error 404 not found. Is it i can't do it like how i access the public folder?

asset('resources/test')

Crazylife started a new conversation How To Set Locale Based On The Language Stored In Database?

I tried to set locale by getting the language stored in database for a user, but it always return null value for user().

class SetLocale
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        dd($request->user()); // return null
      //  app()->setLocale('');

        return $next($request);
    }
}

In kernel.php

'web' => [
            \App\Http\Middleware\SetLocale::class,
]

Is there anything wrong with my step?

12 Jul
10 months ago

Crazylife started a new conversation How To Allow User To View Only And Restrict User Perform Action In Certain Page?

I am seeking for advice on how to setup for a user to view only or perform action on certain page. For example, user A can perform action by clicking button on certain page, while user B only allow to view without performing any action. How do you guys handle for the user, if there's user same role but different permission?

Crazylife left a reply on Anyone Facing Barcode Generator Using Milon/barcode Package Got Issue When Displaying?

@toby I tried {!! DNS1D::getBarcodeSVG('123', "C39", 1, 25, '#2A3239') !!} , it worked for me, hehe. The last 3 params is width height and color right?

Crazylife left a reply on Anyone Facing Barcode Generator Using Milon/barcode Package Got Issue When Displaying?

@toby I always having the issue during printing, the barcode always show nothing only the border, i need to close it and print again then it only will appear.