Crazylife

Experience

8,320

0 Best Reply Awards

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

20th August, 2018

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

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?

9th August, 2018

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

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?

1st August, 2018

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

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? • 2 weeks ago

@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? • 2 weeks ago

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?

27th July, 2018

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

@bobbybouwmann i got this problem after using double _

Call to undefined function __()

26th July, 2018

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

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?

14th July, 2018

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

@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? • 1 month ago

@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? • 1 month ago

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? • 1 month ago

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?

12th July, 2018

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

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? • 1 month ago

@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? • 1 month ago

@toby Are you using google chrome to test it?

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

@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.

Crazylife started a new conversation Anyone Facing Barcode Generator Using Milon/barcode Package Got Issue When Displaying? • 1 month ago

I tried to generate barcode using milon/barcode package, but every first time i generate it shows me blank barcode. Anyone facing same issue as well?

7th July, 2018

Crazylife left a reply on How To Set Different Language For A Defined Variable? • 1 month ago

@BishoyWagih Right now, i just need to translate some messages instead of the web application.

Crazylife started a new conversation How To Set Different Language For A Defined Variable? • 1 month ago

I am going to translate message content in different language based on user. In my controller, i have return the message content. For example,

$msg = "Request From :" .$name;
$msg.= "Date :".$date;

return $msg;

I know it can simply use if else statement, but if the language grow big will caused the function very long. How to handle this? How can i translate the Request From and Date into different language?

4th July, 2018

Crazylife started a new conversation How To Print A Html Content Using Label Printer? • 1 month ago

I want to print html content using label printer, anyone got similar example to show how to make it? I tried mine, the second page always not in correct alignment will be cut off.

28th June, 2018

Crazylife started a new conversation How To Do Grouping Based On Column When Create Excel Using Laravel Maatwebsite? • 1 month ago

Is there any function in laravel maatwebsite excel allow to do grouping and subtotal based on column details?

23rd June, 2018

Crazylife left a reply on How To Select From Subquery Using Eloquent? • 1 month ago

This is what i had done

$sub = SalesTable::select(DB::raw('field1,field3,SUM(field2)as total'))         
              ->groupBy('field1',DB::raw('field3 having total<> 0'));   

 $main = DB::table(DB::raw("({$sub->toSql()}) as sub") )
            ->select('field1', 'field3','total');
            $main ->mergeBindings($sub_breakdown->getQuery());
            $main ->groupBy('field1');       
            $main ->get();

And dd($main) return me this

Builder {#2361 ▼
  #connection: MySqlConnection {#2148 ▶}
  #grammar: MySqlGrammar {#2149 ▶}
  #processor: MySqlProcessor {#2150}
  #bindings: array:6 [▶]
  +aggregate: null
  +columns: array:2 [▶]
  +distinct: false
  +from: Expression {#2364 ▶}
  +joins: null
  +wheres: null
  +groups: array:1 [▶]
  +havings: null
  +orders: null
  +limit: null
  +offset: null
  +unions: null
  +unionLimit: null
  +unionOffset: null
  +unionOrders: null
  +lock: null
  #backups: []
  #bindingBackups: []
  #operators: array:29 [▶]
  #useWritePdo: false
}

I am not sure it is working or not, but i cant get my result although there is no error.

Crazylife started a new conversation How To Select From Subquery Using Eloquent? • 1 month ago

I am using laravel 5.3. I want to achieve something like this using eloquent.

select field1, field2
from (select field1, field3, sum(field2) as total
      from sales
      group by field1, field2
      having total <> 0
     ) s
group by field1;

How can i do this using eloquent?

21st June, 2018

Crazylife left a reply on How To Get The Sum Quantity Of Stock Available For Each Franchise Based On Stock Transaction? • 1 month ago

@bobbybouwmann yeah, i can write in my controller. But, no idea how to start it in controller at this moment.

Crazylife left a reply on How To Get The Sum Quantity Of Stock Available For Each Franchise Based On Stock Transaction? • 1 month ago

@bobbybouwmann i can get the result i want calling model in view, but will caused performance issue, so i prefer not to use it. Finding a way to do this i think will be better.

Crazylife left a reply on How To Get The Sum Quantity Of Stock Available For Each Franchise Based On Stock Transaction? • 1 month ago

@bobbybouwmann

$ad = MenuCatalog::leftJoin('transaction', function ($join){
            $join->on('transaction.id_franchise','=','menucatalog.id_franchise')
                ->on('transaction.id_item','=','menucatalog.id_item');
          
        })->whereIn('id_franchise',$options)
            ->select('id_item',
                DB::raw('( SUM(CASE type WHEN 1 THEN format(stock_in,4) ELSE format(stock_out,4) * - 1 END) ) as qty'))
            ->groupBy('id_item')->get();

This is what i tried so far. How can i sum it for each branch and show in column.

Crazylife started a new conversation How To Get The Sum Quantity Of Stock Available For Each Franchise Based On Stock Transaction? • 1 month ago

I need to get the total qty available for each franchise based on per item.

I have menu_catalog table which will link to main table of franchise and item table.

id   id_franchise   id_item
1     1                         1
2    1                         2
3    1                         3
4    2                        1
5    2                        3
6    3                        2

Each of the franchise might contain different items.

For the stock_transaction table

id  id_franchise  id_item  stock_in  stock_out  type  unit_price
1    1                        1               10                                  1         5.00
2   1                        1                                 2                  2         5.00
3   2                       3               10                                  1         3.00

// type : 1 = stock in while 2 = stock out

Expected output :

id_item franchise1 franchise2 franchise3
1              8,40            0,0              0,0
2             0,0               0,0              0,0
3             0,0               10,30           0,0

I have a condition, when type = 1 then SUM the stock_in else SUM stock_out * -1, same for the price. I will store the total qty and total price for each item based on franchise.

I will select all item belong to this 3 franchises, even some item not existed on their menu catalog. The item not belong to the franchise will be return as 0.

How can i do this?

20th June, 2018

Crazylife left a reply on How To Use Eloquent To Get Data From Database If The Table With A Prefix Value? • 2 months ago

solved. using construct and setTable().

Crazylife started a new conversation How To Use Eloquent To Get Data From Database If The Table Have A Prefix Value? • 2 months ago

How to access the database using eloquent way if i have a table with prefix value to determine belong to which user? For example, user A will access to A_table while user B will access to B_table. Inside table all field are same, just different data stored based on user. How can i create a model which allow me to build query using eloquent way instead of query builder? How to differentiate which user access to which database?

17th June, 2018

Crazylife left a reply on When Render A View, Will It Run The Javascript As Well? • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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 • 2 months 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 • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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? • 2 months 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 • 2 months 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 • 2 months 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. • 2 months 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? • 2 months 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 • 2 months ago

Solved it by casting it to object.

Crazylife left a reply on Trying To Get Non Property Object When Looping Array • 2 months 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 • 2 months 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 • 2 months 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.

Edit Your Profile
Update

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