Crazylife

Experience

7,430

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 2 Lessons Completed
  • 0 Favorites

17th June, 2018

Crazylife left a reply on When Render A View, Will It Run The Javascript As Well? • 1 day ago

@topvillas But function inside tag will be generated right?

Crazylife started a new conversation When Render A View, Will It Run The Javascript As Well? • 1 day ago

When rendering a view, will javascript of that view run also? For example

MyController.php

$view = View::make('pages.preview')->render();

// I will not display the preview.blade.php, i want it run some of the javascript function when i call it. Will the function of javascript be triggered?

14th June, 2018

Crazylife left a reply on What Package Can I Use To Convert Html To Pdf Or Image? • 4 days ago

@pardeepkumar Actually i want to do it at backend by convert the view into image or pdf instead of using jquery etc to do it.

Crazylife left a reply on What Package Can I Use To Convert Html To Pdf Or Image? • 4 days ago

@pardeepkumar I have no idea why i am getting class dompdf.wrapper doesnt exist error.

Crazylife started a new conversation What Package Can I Use To Convert Html To Pdf Or Image? • 4 days ago

I tried dompdf and phantom magick, all gaves me error. For dompdf, return me class dompdf.wrapper doesnt exist, while phantom magick return the binary error. i am using laravel 5.3 with php 5.6, is there any package i can use to convert html to pdf or image? thanks.

9th June, 2018

Crazylife left a reply on How To Write The Eloquent For Sql Where The FROM Clause Consist Of Table And Select Statment • 1 week ago

@PercyMamedy ok, can i ask if using query builder then i have 2 @set variable, i just call DB::statement two times?

DB::statement(DB::raw('SET @row_number:=0;'));
DB::statement(DB::raw('SET @ids:="";'));

Crazylife started a new conversation How To Write The Eloquent For Sql Where The FROM Clause Consist Of Table And Select Statment • 1 week ago

SELECT @row_number:=CASE WHEN @id_category=id_category THEN @row_number+1 ELSE 1 END AS row_number,@id_category:=id_category AS id_category
FROM products, (SELECT @row_number:=0,@id_category:='') AS test  
ORDER BY `id_category` 

How can i transform this sql raw query by using eloquent method? No idea on how to write it in eloquent way for this statement

FROM products, (SELECT @row_number:=0,@id_category:='')

Thanks.

7th June, 2018

Crazylife started a new conversation How To Make A Portion Of Js Inside A Function Usable And Able To Be Called In Multi View? • 1 week ago

I have a portion of code which need to be reused for multi view. And currently, i created a directories called js in my pages, and a blade.php inside js folder.

//details.blade.php inside js folder

............................ // any related code

i simply throw the code inside the details.blade.php. After that in my view, script function i will include this blade.


function($args1,$args2){
@include(js.details)
...... and other code here.
}

I think this is not the correct way to do it, am i right? How you guys manage it?

ps: i am not reusing the function but only some of the code which the function contain.

6th June, 2018

Crazylife left a reply on How To Pass The Variable Returned From Another Controller To The View In Another Controller? • 1 week ago

@tykus Ok, thanks. I am willing to try out too, if you have a better suggestion on this.

Crazylife left a reply on How To Pass The Variable Returned From Another Controller To The View In Another Controller? • 1 week ago

Is it right way to do it if i return the view by controlling the condition and in the controller i want just return $this->test(); ?

Crazylife left a reply on How To Pass The Variable Returned From Another Controller To The View In Another Controller? • 1 week ago

So if the test() variable consist of array and single value, how can i return the variable data and pass to the view? As i know i can return it in array form and getTest() will get the array variable and pass to view?

Crazylife left a reply on How To Pass The Variable Returned From Another Controller To The View In Another Controller? • 1 week ago

@tykus I am doing something like this

//class Controller2 extends Controller

public function test(){
$varA = Model::where(...)->get();
$varB = Model2::where(...)->get();
$varC = Model3::where(...)->get();
}

//class Controller extends BaseController

public function getTest(){
return View::make('......', compact('varA','varB','varC'));
}

This is not correct?

Crazylife started a new conversation How To Pass The Variable Returned From Another Controller To The View In Another Controller? • 1 week ago

I want to pass multiple variable get from the function in controller2 and return to view in controller1. How can i make it?

Controller1 extended controller2, i want to return multiple variable get from controller2 and return to controller1 view.

28th May, 2018

Crazylife left a reply on If Else Condition Not Working On Mail::send • 3 weeks ago

@justl00king Inside use is the array explode from a string. If is not empty i will set it as cc email. I tried even if empty it always run the cc statement.

Crazylife started a new conversation If Else Condition Not Working On Mail::send • 3 weeks ago

Mail::send('.......', function($m) use (....){
                                $m->from('...');
                                $m->to(.....)->subject('....');
                                if(....){
                                    $m->cc(....);
                                }
                                });

I tried the if else condition inside the Mail::send, but it keep bypass it even false also will send the cc. Can't i use the if else condition inside the mail send function?

24th May, 2018

Crazylife started a new conversation How To Solve Slow Performance With Nested Looping When A Lots Of Data. • 3 weeks ago

foreach ($id_prs as $ids) {
   list($id_pr, $id_cart) = explode('-', $ids);
    foreach ($ids as $id) {
        $r = Cart::find($id);
                /// column to update value
                $r->save();
    }
}

I found that loop is slow in performance when the second loop involved of a lot of data. How can i solve the performance issue, any solution?

22nd May, 2018

Crazylife started a new conversation How To Add New Array And Append Or Remove An Attribute In An Existing Array To Collection? • 3 weeks ago

This is my result

Collection {#2294 ▼
  #items: array:3 [▼
    0 => Catalog {#2289 ▼
      #primaryKey: "id_product"
      #connection: null
      #table: null
      #keyType: "int"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:4 [▼
        "id_product" => 1
        "name" => "testing product"
        "code" => "ABC0001"
        "uom" => "KG"    
      ]
      #original: array:4 [▶]
      #relations: []
      #hidden: []
      #visible: []
      #appends: []
      #fillable: []
      #guarded: array:1 [▶]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      +exists: true
      +wasRecentlyCreated: false
    }
    1 => Catalog {#2288 ▶}
    2 => Catalog {#2287 ▶}
  ]
}

When i loop this result, how can i do like if condition fulfilled then add a new array to it, or add and remove certain attribute to each array? Is it possible to do it?

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

Solved it by casting it to object.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

@Cronix It gave me an error Undefined property: Illuminate\Support\Collection::$id

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

Ok. I get the result from database table.

$results = User::where('id',$id)->get(); // this is working when using foreach loop

After that i loop it, and store the data into new array.

$b = array();
foreach($results as $val){
$a = array();
$a['id'] = $val->id;
$a['name'] = $val->name;
$b[] = $a;
}

$temp = collect($b);


foreach($temp as $t){
dd($t->id); // trying to get non property of object
dd($t['id']); // should working fine but i want to use the first one
}

When i am trying to loop the array, it doesn't allow me to use $t->id. I tried to cast the array to object but still not working.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

i just want the array i stored to work in $result->id instead of $result['a']. Want to know whether it is possible to do that.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

Not possible to create a new collection which allowed to use like $result->id this method?

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

@tykus nope. I have 2 column which is used to do comparison in a row. E.g. if col1 and col2 have different value then it will return 2 row else 1 row will only be returned.

if col1 value = 1
if col2 value = 1

will return
id | col
1      1


if col1 value = 1
if col2 value = 2

will return
id | col
1      1
1      2

One id will return only maximum 2 row.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

@tykus For example,

$ results = Test::where('id',$id)->get();

I want to rebuild the collection return from this '$results' into a new one by adding some new attribute etc.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

@lostdreamer_nl is that possible to do $val->id; work instead of $a['id'] ?

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

This is the result i get

array:3 [▼
  0 => array:1 [▼
    0 => array:1 [▼
      "id" => 1
    ]
  ]
  1 => array:2 [▶]
  2 => array:3 [▶]
]

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 3 weeks ago

@Mahmoudy same, not working.

Crazylife started a new conversation Trying To Get Non Property Object When Looping Array • 3 weeks ago

I am creating a new array by looping when getting the result from a table get(). ··· $a = array(); $b = array(); foreach($results as $val){ $a['id'] = $val->id; $a['name'] = $val->name; $b[] = $a; }

$temp = collect($b);

foreach($temp as $t){ dd($temp->id); }

···

When i am trying to loop $temp, it returns trying to get non property object when looping. How can i do it in this way to get the value from array by using ($temp->id) ?

15th May, 2018

Crazylife left a reply on How To Detect User Is Login Using Mobile Apps Or Web Apps In Laravel? • 1 month ago

Just want to know whether it's an Mobile Apps or Web, all activity accessed by browser consider as Mobile Apps.

Crazylife left a reply on How To Detect User Is Login Using Mobile Apps Or Web Apps In Laravel? • 1 month ago

@Cronix By use this, i only can know whether it is desktop or mobile. I don't know it's an apps or mobile browser.

Crazylife started a new conversation How Mobile Apps For Ionic With Laravel Can Share The Same Global Variable With Web? • 1 month ago

For the mobile apps build in Ionic Framework with Laravel, can it use the app service provider same as web apps?

Is there a way to share variable between mobile and web? For example, when mobile login then the variable will be stored and web there can get the variable and do something.

Crazylife left a reply on How To Detect User Is Login Using Mobile Apps Or Web Apps In Laravel? • 1 month ago

@Snapey yes, different controller. But sharing same Model function. The reason i want to find other way is because of needed to change a lot of function that involved both when detection for web or mobile apps needed to store in database.

Crazylife started a new conversation How To Detect User Is Login Using Mobile Apps Or Web Apps In Laravel? • 1 month ago

There's a package for detect between desktop and mobile.

Agent::isDesktop();
Agent::isMobile();

For desktop, it always detect as Web application. But, for mobile user might login using browser or mobile apps, from here how can i detect whether it is browser or mobile apps?

30th April, 2018

Crazylife started a new conversation How To Add Dynamic Label Data To The Adminlte Side Bar Navigation Without Building Menu? • 1 month ago

Hi there, i want to count a dynamic data which get from database and display as label beside the navigation link. I am using this package jeroennoten/Laravel-AdminLTE.

 $usersCount = User::count();

        $event->menu->add('MAIN NAVIGATION');
        $event->menu->add([
            'text'        => 'Users',
            'url'         => 'admin/users',
            'icon'        => 'users',
            'label'       => $usersCount,
            'label_color' => 'success'
        ]);

I can do something like this using building menu, but most of my sidebar inside config/adminlte.php. Instead of using building menu to build my sidebar menu, is there any solution or trick to make it work without using building menu? Thanks.

26th April, 2018

Crazylife left a reply on How To Get Data From Relationship Table Using Laravel Eloquent Model? • 1 month ago

@Vilfago let's say they have the same value but the key naming( tableA is id & tableB is test_id) is different? Will they link or is there a way to make it?

Crazylife left a reply on How To Get Data From Relationship Table Using Laravel Eloquent Model? • 1 month ago

@biishmar if tableA primary key is id and tableB foreign key is test_id, can it work?

Crazylife started a new conversation How To Get Data From Relationship Table Using Laravel Eloquent Model? • 1 month ago

This is my model

public function test()
        //region
    {
        return $this->belongsTo('App\Models\Test', 'id_product');
    }

in my blade i will loop it

foreach($products as $product){
            $products_id = $product->products_id;
    }

I have a question on, can i get the data from relationship table using eloquent model if the value stored format is different for foreign?

For example, the primary key in table product is abc_001. And foreign key in another table is admin_abc_001. By doing some filter or condition on the value so is that possible i loop it like this?

foreach($products as $product){
            $products_id = $product->test->col_1;
    }

17th April, 2018

Crazylife started a new conversation How To Implement The OnOpen Function From Sweetalert 2 Into Sweetalert 1? • 2 months ago

I need the onOpen function from sweetalert 2, example like show datepicker when show the alert box. I cannot directly use sweet alert 2 because of different structure from sweet alert 1. It might required me to change a lot for my UI. Any idea how to do this? Just want to add the function into the sweetalert.min.js to make the onOpen function work.

16th April, 2018

Crazylife started a new conversation Input Field Unable To Edit Or Made Changes In Sweet Alert • 2 months ago

swal({
                title: "Confirm details?",
                text:'<input type="text" id="datetimepicker" class="form-control">',
                type: "warning",
                customClass: 'swal-custom-width',
                html:true,
                showCancelButton: true,
                confirmButtonClass: "btn-success",
                confirmButtonText: "Confirm",
                cancelButtonText: "Cancel",
                closeOnConfirm: false,
                closeOnCancel: false,
                showLoaderOnConfirm: true
            },

The input field will not display until I am applying css on it to display.

display : initial

Then, the sweet alert box display the text field but not allow to edit or make changes.

What's wrong with this?

7th April, 2018

Crazylife left a reply on Query Perform Very Slow When Using Where In Condition • 2 months ago

After i get the items return from query i am using lengthawarepaginator to show my items.

Crazylife left a reply on Query Perform Very Slow When Using Where In Condition • 2 months ago

@Nash $id_items_default is the items get from another table, where only return id_item.

Crazylife left a reply on Query Perform Very Slow When Using Where In Condition • 2 months ago

@Snapey for all the id

Crazylife left a reply on Query Perform Very Slow When Using Where In Condition • 2 months ago

@Nash Yes i already using index.

Crazylife started a new conversation Query Perform Very Slow When Using Where In Condition • 2 months ago

I am having this query.

$items = DB::table('items')
               ->leftJoin('default_price', 'items.id_item', '=', 'price_default.id_item')
               ->leftJoin('vendors', 'items.id_vendor', '=', 'vendors.id_supplier')
               ->whereIn('items.id_vendor', $vendors)
               ->whereIn('items.id_item', $id_items_default)
               ->get()->toArray();

There's around 90 vendors and 10k items.

->whereIn('items.id_item', $id_items_default)

This condition caused whole performance slow down about 20 sec. How can i make it perform faster even with huge data? Thanks in advance.

27th March, 2018

Crazylife left a reply on BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

This is in my user model

 public function checkSomething($id)
    {
        $branch = Branch::find($id);
        $bool = true;
        if($branch != null)
        {
           return ($branch->id_check == Auth::user()->id_check);
        } else {
           return false;
        }
    }

Crazylife left a reply on BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

@arukomp if i changed it to capital letter then it shows the class does not exist.

Crazylife left a reply on BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

@arukomp which file you want to view? It works fine before but suddenly not working, i didnt made any changes on it. I have no idea what's wrong with it.

Crazylife left a reply on BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

@Cinek Yes, there is a method call checkSomething inside User model.

Crazylife started a new conversation BadMethodCallException In Builder.php Line 2450: Call To Undefined Method Illuminate\Database\Query\Builder::checkSomething() • 2 months ago

I have a function name checkSomething() inside my User.model

For my web.php route,

 Route::group(['middleware' => 'checkSomething'], function(){
    });

In my kernel.php

'checkSomething' => \App\Http\Middleware\checkSomething::class,

How can i solve this issue? It happens after i composer install some package.

25th March, 2018

Crazylife started a new conversation How To Zip Each Folder In A Directories And Upload It To Somewhere? • 2 months ago

I have a folder in public directories. The folder name as records. Inside the 'records' folder consist of two folder name as 'buyer_records' and 'seller_records'.

I am using this function to store the relevant file into these two folder.

 Storage::disk('uploads')->put('/buyer_records/'.$file, $contents);
 Storage::disk('uploads')->put('/seller_records/'.$file, $contents);

I want to zip each of the folder inside 'records' folder. For example,

buyer_records_180325.zip
seller_records_180325.zip

The naming of folder will follow by the original naming of folder just append the date on it.

How can i do this?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.