kundefine

kundefine

Member Since 11 Months Ago

Dhaka

Laravel Developer at ColourSpray

Experience Points 1,430
Experience Level 1

3,570 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 1
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

14 Jul
1 week ago

kundefine started a new conversation How Can I Sort Storage File

I want to sort all the files by 'created date'

Storage::disk('media')->allfiles(); 

// return array of all my filenames

/*[
     "golf-ba-ckg-ro-u-nd-1.jpg",
     "golf-ba-ckg-ro-u-nd-2.jpg",
     "golf-ba-ckg-ro-u-nd.jpg",
     "image-1-3.jpg",
     "image-10.jpg",
     "image-2-2.jpg",
     "image-3-2.jpg",
     "image-5-2.jpg",
     "image-6-2.jpg",
     "image4-1.jpg",
     "image4.jpg",
     "malaysia--ringgit--banknotes--falls-on-black-background-4k-clip-normal-speed_n1glvblm-l__f0000.png",
     "old-grunge-cement-wall-backgrounds_34552-195.jpg",
     "screenshot-1.jpg",
     "screenshot-2.jpg",
     "screenshot.jpg",
     "slider-1.jpg",
     "slider-logo-1.png",
     "slider-logo.png",
   ] */



08 Jul
2 weeks ago

kundefine started a new conversation Upload File To Disk

In public disk I don't understand what's is the difference between "root" and "url" in disk config. I know that "root" is the path where i will upload my file but what about "url" and why i need it.

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'), // where i want to upload my file
            'url' => env('APP_URL').'/storage', // why i need url over here
            'visibility' => 'public',
        ],

15 Jun
1 month ago

kundefine left a reply on Get Dynamic Csrf Token

@JOHNBRAUN - I read all the comment. I added my whole function to a category-ui.balde.php like below and it works.

category-ui.blade.php

<?php
    function getTreeAshtml($nodeTrees) {
    static $child_label = 0;
    $output = '';
    $output .= "<ul class='parent'>";
        foreach ($nodeTrees as $tree) {
        $output .= "<li class='child menu-id-{$tree->id} child-{$child_label}'>";
            $output .= '<input type="checkbox" name="categories[]" value="'. $tree->id .'" >' . $tree->name . " ({$tree->slug})";
            $output .= "<br><input type='text' class='child_category_input_value'><button class='category_create_button' id='$tree->id'>Create Child</button>";
            if(count($tree->children)) {
                $child_label++;
                getTreeAshtml($tree->children);
            } else {
                $child_label = 0;
            }
            $output .=  "</li>";
        }
        $output .= 'Create Parent: <form action="/category" method="post"><input type="text"><input type="submit" value="Submit" id="createCategoryParent"></form>';
        $output .= "</ul>";
    return $output;
    }
?>

kundefine left a reply on Get Dynamic Csrf Token

@cronix @johnbraun now i am trying to use as blade component. Now I have a problem with function recursion. because my function use recursion. I need to explain what i really want to do. I have Category and Category has Child and Child has his own child. I want to show the category as tree and also create the child and parent over here.

getTreeAshtml($nodeTrees) function has a recursion to display child if has child.
at end of the function it has a form for create a parent. with csrf_field() that doesn't work.
public static function getTreeAshtml($nodeTrees) {
        static $child_label = 0;
    $output = '';
        $output .= "<ul class='parent'>";
            foreach ($nodeTrees as $tree) {
                $output .= "<li class='child menu-id-{$tree->id} child-{$child_label}'>";
                $output .=  $tree->name . " ({$tree->slug})";
        // input and a submit button to create child of a parent
                $output .= "<br><input type='text' class='child_category_input_value'><button class='category_create_button' id='$tree->id'>Create Child</button>";
        // if has any child
                    if(static::hasChild($tree)) {
                        $child_label++;
                        static::getTreeAshtml($tree->children);
                    } else {
                        $child_label = 0;
                    }
                $output .=  "</li>";
            }
        $output .= "</ul>";
    // create the parent form
        $output .= 'Create Parent: <form action="/category" method="post">'. csrf_field() .'<input type="text"><input type="submit" value="Submit" id="createCategoryParent"></form>';
        return $output;
    }

now i am trying to getTreeAshtml($nodeTrees) function to blade component. but how i will convert it as blade component because the function use a recursion.

13 Jun
1 month ago

kundefine left a reply on Get Dynamic Csrf Token

@JOHNBRAUN - I never use component in laravel. but i will try. but if you have any other solution feel free to know me. thanks.

kundefine left a reply on Laravel Error 500, Welcome Page Not Loading

check your .env file for APP_KEY present if not generate it with this command -> php artisan key:generate Example: APP_KEY=base64:BIS6IJfT/vskVdfdQPjlxBM+yiNvwfaNLqDLFkAlaRU=

kundefine left a reply on Get Dynamic Csrf Token

@JOHNBRAUN - csrf_token() value is always null. I just updated my post. please take a look, you will find what i really want to say

kundefine started a new conversation Get Dynamic Csrf Token

i have function that generate a form from a model

Category Model:

public static function generateForm() {
    $output = '';

    $output .= '<form action="/category" method="post">
                    '. csrf_field() .'
                    <input type="text">
                    <input type="submit" value="Submit" id="">                      
                </form>'
}

It's not working In my view it's showing the hidden input token but doesn't get any value.

22 May
2 months ago

kundefine started a new conversation How To Get All The Namespace Group Route

How i will get all the group namespace route.

21 May
2 months ago

kundefine left a reply on Prefix Route Problem

@SERGIU17 - Thanks Bro

kundefine left a reply on Prefix Route Problem

@SERGIU17 - Yes i have.

kundefine started a new conversation Prefix Route Problem

test.com/dashboard not working. give me this error

Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

Error 403 colorspray.ku Apache/2.4.38 (Win64) OpenSSL/1.1.1b PHP/7.3.3

Route::prefix('/dashboard')->group(function(){
    Route::get('/', 'Backend\[email protected]')->name('dashboard');
});

20 May
2 months ago

kundefine left a reply on Csrf Token Mismatch

I think u need something below

<meta name="csrf-token" content="{{ csrf_token() }}">

<script>
$.ajax({
    type: 'POST',
    url: '/your/route',
    headers: {
           'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
})
</script>

kundefine left a reply on WYSIWYG Image Upload

@MEMELE - where u get the error. are you trying upload the image in your file or you want to store the image in database as base64 file

kundefine left a reply on Middleware Supports

check your Auth::gurad('company') or Auth::gurad('company')->user() is an object or not

kundefine left a reply on WYSIWYG Image Upload

I think u need this in your html and your script

<meta name="csrf-token" content="{{ csrf_token() }}">

<script>
$('#editor')
.trumbowyg({
    btns: ['upload'],
    plugins: {
        // Add imagur parameters to upload plugin for demo purposes
        upload: {
            serverPath: 'https://api.imgur.com/3/image',
            fileFieldName: 'image',
            headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            urlPropertyName: 'data.link'
        }
    }
});
</script>

kundefine left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given

@ETERNALCHAOS520 - its an regular array you can use all the regular array think u do in your regular php life

kundefine left a reply on Laravel Share Variable In All Views As Reference

@BOBBYBOUWMANN - You just say use the blade#service-injection i use it and it give me the same initial value of the $css->publicProperty.

kundefine left a reply on Slug

In my Page Model I create this two static function that check if slug exits make new one or create new one from the slug title. you can use something like below

Threads::makeNewSlug("pass the title")  // it will return pass-the-title or if exits it will return pass-the-title-1
    // check slug exits
    public static function checkSlugExits($slug_title) {
        if(static::all()->count() > 0) {
            $slug_found = static::where('slug', $slug_title)->get()->all(); // your database table should have slug column in the Model or change it according to your column name
            if( !empty($slug_found) ) {
                return true;
            } else {
                return false;
            }
        }
    }

    // make new slug if slug exists
    public static function makeNewSlug($prev_slug) {
        $prev_slug = strtolower(str_replace(' ', '-', trim($prev_slug)));
        static $inc = 1;
        if(static::checkSlugExits($prev_slug)) {
            $newslug = $prev_slug . '-' . $inc++;
            return static::makeNewSlug($newslug);
        } else {
            return $prev_slug;
        }
    }


kundefine left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given

use something like this it will work. But I think you know how to manipulate array in php


<div class="container">
    <div class="row">
        <div class="col-sm">
            <table>
                <tr>
                    <td>CHILD PART</td>
                    <td colspan="2">MATERIAL</td>
                    <td>GRADE</td>                    
                </tr>
                <tr>
                    <td>{{ implode(" ", $sc['sc_cp']) }}</td>
                    <td colspan="2">{{ implode(" ", $sc['sc_material']) }}</td>
                    <td>{{implode(" ",  $sc['sc_grade']) }}</td>                    
                </tr>
            </table>
        </div>
    </div>
</div>



kundefine left a reply on How To Pass A Variable To A Function With Callback?

Why not u use the second argument to pass the data

function doIt($callback, $data) {
    $callback($data);
}

$data = "Your data is here";

doIt(function($data) {
    echo 'Anonymous function: ' . $data;
}, $data);
19 May
2 months ago

kundefine left a reply on Laravel: Dynamically Add And Remove CSS Or Script

@SNAPEY - I know i can do that. But what if i don't need some master css file in pages. include is easy but how to exclude.

@extends('dashboard.layouts.master')

@section('page-css')

    {{-- add any additional css for index page ==}}

@endsection

@section('exclude-css')

    {{-- remove any css that comes from master layout ==}}

@endsection


@section('main-content-section')

@endsection


@section('script')
@endsection
18 May
2 months ago

kundefine left a reply on Laravel Share Variable In All Views As Reference

@BOBBYBOUWMANN - @bobbybouwmann that doesn't work for me. I added a new thread what i really want to do https://laracasts.com/discuss/channels/laravel/laravel-dynamically-add-and-remove-css-or-script pls give any feedback if you have any.

kundefine started a new conversation Laravel: Dynamically Add And Remove CSS Or Script

It is really easy to include all the common CSS or Script in the page. But the problem arise when you don't need some CSS or Script in the page. If you checkout my below code you will find out what i am trying to say.

I already instantiate my CSS class in header.blade.php and its included in the master.blade.php. After that index.blade.php extends master.blade.php

But the problem is When index.blade.php render it's create a new instance of the CSS class. header instance is gone.

I am trying to use my CSS Class

=> as service provider
=> share as view variable
=> as a Facade
  1. CSS.php (myclass for add or remove css)
namespace App\AppGlobal;

class CSS {
    public $css = []; // all my css filename and path is store in here

    // add css
    public function add($path, $filename) {
        $path = asset($path);
        $this->css[$filename] = $path;

        return $this->css;
    }


    // remove css
    public function remove($filename) {
        if(array_key_exists($filename, $this->css)) {
            unset($this->css[$filename]);
        }
    }

    // print css
    public function print() {
        $output = '';
        if(count($this->css)) {
            foreach($this->css as $filename => $path) {
                $output .= "<link rel='stylesheet' href='{$path}/{$filename}'>\n";
            }
        }
        echo $output;
    }
}

  1. master.blade.php (look like below)
{{-- include tha header --}}
@include('dashboard.inc.header')

{{-- the main content section --}}
@yield('main-content-section')

{{-- include tha footer --}}
@include('dashboard.inc.footer')
  1. header.blade.php (look like below)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{{config('app.name', 'ColorSpray')}}</title>

    {{-- add all common css --}}
    <?php $css->add('some/path', 'filename.css') ?>
    {{-- add additional css--}}
    @stack('add-css')
    {{-- remove exitsing css--}}
    @stack('remove-css')
    {{-- print all my css --}}
    <?php $css->print(); ?>
</head>
<body>
  1. index.blade.php (index.blade.php extends master.blade.php)
@extends('dashboard.layouts.master')

@push('add-css')
    {{-- add any additional css for index page --}}
    <?php
        $css->add('your/path/name', 'filename.css');
    ?>

@endpush

@push('remove-css')
    {{-- remove any common css that i don't need in index page --}}
    <?php
        $css->remove('your/path/name', 'commonFilename.css');
    ?>
@endpush


@section('main-content-section')

@endsection


@section('script')
@endsection
16 May
2 months ago

kundefine started a new conversation Laravel Share Variable In All Views As Reference

I really want a very simple thing

  1. I Share a global variable from AppServiceProvider like below
public function boot() {
    view()->share('css', new CSS());
}
  1. I set some property values it In a View (index.blade.php) like blow
$css->publicProperty = "Something"; // changed in index.blade.php
  1. In another View (contact.blade.php) i check the $css->publicProperty variable but it doesn't give me the change value
dd($css->publicProperty) // give me the initial value in contact.blade.php

Now i need a way that share a variable as global also as reference. So that i change in one view and it will retain the change in other views also