me10071990

me10071990

Member Since 2 Months Ago

Experience Points 970
Experience Level 1

4,030 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 0
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.

13 Jun
5 days ago

me10071990 left a reply on How To Display Multiple Post In Single Blade By Using Two Row(example Starting Post, Expired_date Post)

public function events($slug)

{

$post = Post::where('slug', $slug)->first();

$coming_events = Post::where('id', '>', $post->id)->desc('id'); $past_events = Post::where('id', '<', $post->id)- >asc('id');

 return view('events_blade')

   ->with('post', $post)
   ->with('categories', Category::take(7)->get())
   ->with('next', Post::find($coming_events))
   ->with('prev', Post::find($past_events));

} }

me10071990 left a reply on How To Display Multiple Post In Single Blade By Using Two Row(example Starting Post, Expired_date Post)

Thanks for reply @snapey :)...yeah,,I put the same question but i didn't paste my code, now I try with the same but still not working.

class FrontendController extends Controller { public function welcome()

{

@TODO Refactor This Line return view('welcome')

->with('title', Setting::first()->site_name)
->with('levels', Category::take(7)->get())

->with('levels', Category::take(7)->get())
->with('first_post', Post::orderBy('created_at','asc')->first())
->with('second_post', Post::orderBy('created_at', 'asc')->skip(1)->take(1)->get()->first())
->with('third_post', Post::orderBy('created_at','asc')->skip(2)->take(2)->get()->first())
->with('forth_post', Post::orderBy('created_at','asc')->skip(3)->take(3)->get()->first())
->with('HOME', Category::find(1))
->with('ABOUT US', Category::find(2))
->with('RESEARCH', Category::find(3))
->with('NEWS AND PUBLICATION', Category::find(4))
->with('EVENTS', Category::find(5))
->with('PEOPLE', Category::find(6))
->with('CONTACT US',Category::find(7));

}

public function singlePost($slug)

{ $post=Post::whereSlug($slug)->first();

return view('single')->with('post', $post)

                        ->with('content', $post)

                       ->with('levels', Category::take(7)->get());

}

Public function category($slug)

{ $category=Category::whereSlug($slug)->firstOrFail();

return view($category->getTemplateFile())->with('category', $category)

                         ->with('title',$category->name)

                         ->with('levels', Category::take(7)->get());

}

public function events($slug)

{

$post = Post::where('slug', $slug)->first();

$coming_events = Post::where('id', '>', $post->id)->desc('id'); $past_events = Post::where('id', '<', $post->id)- >asc('id');

 return view('events_blade')

   ->with('post', $post)
   ->with('categories', Category::take(7)->get())
   ->with('next', Post::find($coming_events))
   ->with('prev', Post::find($past_events));

}

}

me10071990 started a new conversation How To Display Multiple Post In Single Blade By Using Two Row(example Starting Post, Expired_date Post)

I have a category page created by template and in this I want to display two types of box in single page, one is starting_post and old_post or expired, how can divide a single page in two part?

here is code

class FrontendController extends Controller { public function welcome()

{

// @TODO Refactor This Line
return view('welcome')

    ->with('title', Setting::first()->site_name)
    ->with('levels', Category::take(7)->get())

    ->with('levels', Category::take(7)->get())
    ->with('first_post', Post::orderBy('created_at','asc')->first())
    ->with('second_post', Post::orderBy('created_at', 'asc')->skip(1)->take(1)->get()->first())
    ->with('third_post', Post::orderBy('created_at','asc')->skip(2)->take(2)->get()->first())
    ->with('forth_post', Post::orderBy('created_at','asc')->skip(3)->take(3)->get()->first())
    ->with('HOME', Category::find(1))
    ->with('ABOUT US', Category::find(2))
    ->with('RESEARCH', Category::find(3))
    ->with('NEWS AND PUBLICATION', Category::find(4))
    ->with('EVENTS', Category::find(5))
    ->with('PEOPLE', Category::find(6))
    ->with('CONTACT US',Category::find(7));

}

public function singlePost($slug)

{ $post=Post::whereSlug($slug)->first();

return view('single')->with('post', $post)

                            ->with('content', $post)

                           ->with('levels', Category::take(7)->get());

}

public function category($slug)

{ $category=Category::whereSlug($slug)->firstOrFail();

return view($category->getTemplateFile())->with('category', $category)

                             ->with('title',$category->name)

                             ->with('levels', Category::take(7)->get());

}

public function events($slug) { $post = Post::where('slug', $slug)->first();

$coming_events = Post::where('id', '>', $post->id)->desc('id'); $past_events = Post::where('id', '<', $post->id)->asc('id');

return view('events_blade')

   ->with('post', $post)
       ->with('categories', Category::take(7)->get())
       ->with('next', Post::find($coming_events))
       ->with('prev', Post::find($past_events));

}

}

12 Jun
6 days ago

me10071990 started a new conversation Ho Can Compare Two Post In Single Blade By Date?

I have PEOPLE.blade menu section in this I have two row one is new post and one is old post, I want to arrange by date, I am trying to put the logic but not working. what I have to do next thanks

this is my view.blade(peolple)

@extends('layouts.frontend')

@section('content')

<div style="background-image:url(/app/images/head/event.jpg)"class="wrap-slider my-wrap-slider ">
    <div class="container page-container">
        <div class="page-content">
            <div class="page-title">
                <h1 class="tshadow">{{$category->name}}</h1>

            </div><!-- page-title -->
        </div>
    </div><!-- container -->
</div><!-- wrap-slider -->
<section class="flat-row pd-blog bg-theme blog-list3 blog-list3-style2">
    <div class="container">
        <div class="wrap-post">
            New people
            <div class="row">

                @foreach($category->posts as $post)
                <div class="col-md-12 wrap-grid">
                    <article class="entry">
                        <div class="row">
                            <div class="col-md-8 col-sm-8">
                                <div class="entry-post">
                                    <div class="entry-meta">
                                        <span>{{ \Carbon\Carbon::parse($post->date_time)->format('j F, Y')  }}</span>

                                    </div>
                                    <h3 class="entry-title">{{ $post->title }}</h3>

                                    <div class="entry-content">
                                        <a  target="_blank" href="{{ asset("$post->file") }}"><p style="font-size: 18px;color: #468b10;">   {{ $post->content }}</p></a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-sm-4">
                                <div class="feature-post">
                                    @if ($post->featured)

                                  <img src="{{ $post->featured }}" alt="image"></a>
                                </div>

                                @endif
                            </div>
                        </div>
                    </article>



                </div><!-- col-md-6 -->

                @endforeach
            </div><!-- row -->
        </div><!-- wrap-post -->

            Old people

        <div class="row">

            @foreach($category->posts as $post)
                <div class="col-md-12 wrap-grid">
                    <article class="entry">
                        <div class="row">
                            <div class="col-md-8 col-sm-8">
                                <div class="entry-post">
                                    <div class="entry-meta">
                                        <span>{{ \Carbon\Carbon::parse($post->date_time)->format('j F, Y')  }}</span>

                                    </div>
                                    <h3 class="entry-title">{{ $post->title }}</h3>

                                    <div class="entry-content">
                                        <a  target="_blank" href="{{ asset("$post->file") }}"><p style="font-size: 18px;color: #468b10;">   {{ $post->content }}</p></a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-sm-4">
                                <div class="feature-post">
                                    @if ($post->featured)

                                        <img src="{{ $post->featured }}" alt="image"></a>
                                </div>

                                @endif
                            </div>
                        </div>
                    </article>



                </div><!-- col-md-6 -->

            @endforeach
        </div><!-- row -->
    </div><!-- wrap-post -->

    </div><!-- container -->
</section>

@endsection

here is part of postController

/ Create Initial Required Data Array $data = [

        'link'=>$request->link,
        'title'=>$request->title,
        'content'=>$request->content,
        'category_id'=>$request->category_id,
        'slug'=>str_slug($request->title),
        'date_time' => Carbon::parse($request->date_time)->format('Y-m-d'),

    ];
11 Jun
1 week ago

me10071990 left a reply on I Have Uploaded The Pdf Link On Website And When Clicked On Link It's Not Showing Pdf File.

Still showing something notwell..

when click on pdf link my url is http://localhost/storage 404 |not found

here is view

{{ $post->title }}

                                    <div class="entry-content">
                                        <a  target="_blank" href="{{ Storage::url($post->file) }}"><p style="font-size: 18px;color: #468b10;">   {{ $post->content }}</p></a>
                                    </div>

me10071990 left a reply on I Have Uploaded The Pdf Link On Website And When Clicked On Link It's Not Showing Pdf File.

public function getDocument($id) { $data = Post::findOrFail($id);

    $file = $data->file_name;

    // file not found
    if( ! Storage::exists($file) ) {
        abort(404);
    }

    $pdfContent = Storage::get($file);

    // for pdf, it will be 'application/pdf'
    $type       = Storage::mimeType($file);
    $file_name   = Storage::name($file);

    return Response::make($pdfContent, 200, [
        'Content-Type'        => $type,
        'Content-Disposition' => 'inline; filename="'.$file_name.'"'
    ]);
}

now I have chnaged

me10071990 left a reply on I Have Uploaded The Pdf Link On Website And When Clicked On Link It's Not Showing Pdf File.

here is store method in which I am saving all

public function store(Request $request) { $this->validate($request, [

        'title' =>'required',
        'link'=>'required',
        'date_time'=>'required',
        'featured'=>'mimes:jpeg,pdf,docx,png:5000',
        'file'=>'mimes:jpeg,pdf,docx,png:5000',
        'content'=>'required',
        'category_id'=>'required',


    ]);

    // Create Initial Required Data ARray
    $data = [

        'link'=>$request->link,
        //'date_time'=>$request->date_time,
        'title'=>$request->title,
        'content'=>$request->content,
        'category_id'=>$request->category_id,

        'slug'=>str_slug($request->title),

        'date_time' => date("Y-m-d H:i:s", strtotime(request('date_time'))),

    ];

    if(request('link'))
    {
        $link=request('link');

    }
    // Optionally add 'featured' if found to the Data array
    if (request('featured'))
    {
        $featured = request('featured');
        $file_name = time() . $featured->getClientOriginalName();
        $featured->move('uploads/posts', $file_name);
        $data['featured'] = 'uploads/posts/'.$file_name;
    }

    // Optionally add 'file' if found to the Data array
    if (request('file')) {
        $file = request('file');
        $file_name = time() . $file->getClientOriginalName();
        $file->move('uploads/posts', $file_name);
        $data['file'] = 'uploads/posts/'.$file_name;

    }
    // Create the Post with the $data Array

   $post = Post::create($data);


    Session::flash('success', 'New Blog has been Published on Website for Particular Menu');

    return redirect()->back();

}

me10071990 left a reply on I Have Uploaded The Pdf Link On Website And When Clicked On Link It's Not Showing Pdf File.

@snapey , thanks, i have saved in data base, so what should I have to pass in show method

me10071990 started a new conversation I Have Uploaded The Pdf Link On Website And When Clicked On Link It's Not Showing Pdf File.

view

{{ $post->content }}

Controller

public function show($id)

{

    $file=Post::find($id);

    $content = base64_decode($file->content);

    return response($content)->header('Content-Type', $file->file);

}

public function store(Request $request) {

if (request('file'))

{

    $file = request('file');

    $file_name = time() . $file->getClientOriginalName();

    $file->move('uploads/posts', $file_name);

    $data['file'] = 'uploads/posts/'.$file_name;

}

}

06 Jun
1 week ago

me10071990 started a new conversation I Have Dynamic Category And Subcategory On My Website, I Am Able To Post My Data In Menu Page Only But Don't Have Idea To How To Post Data Under Subcategory.

This is my Controller for post..

public function store(Request $request) { $this->validate($request, [

        'title' =>'required',
        'opt_1'=>'required',
        'opt_2'=>'required',
        'featured'=>'mimes:jpeg,pdf,docx,png:5000',
        'file'=>'mimes:jpeg,pdf,docx,png:5000',
        'content'=>'required',
        'category_id'=>'required',


    ]);

    // Create Initial Required Data ARray
    $data = [

        'opt_1'=>$request->opt_1,
        'opt_2'=>$request->opt_2,
        'title'=>$request->title,
        'content'=>$request->content,
        'category_id'=>$request->category_id,


        'slug'=>str_slug($request->title)
    ];

    if(request('opt_1'))
    {
        $opt_1=request('opt_1');

    }




    // Optionally add 'featured' if found to the Data array
    if (request('featured'))
    {
        $featured = request('featured');
        $file_name = time() . $featured->getClientOriginalName();
        $featured->move('uploads/posts', $file_name);
        $data['featured'] = 'uploads/posts/'.$file_name;
    }

    // Optionally add 'file' if found to the Data array
    if (request('file')) {
        $file = request('file');
        $file_name = time() . $file->getClientOriginalName();
        $file->move('uploads/posts', $file_name);

// $content = base64_encode(file_get_contents($_FILES['pdf'['tmp_name']));

        $data['file'] = 'uploads/posts/'.$file_name;


        //$data->content=$content;
    }



    // Create the Post with the $data Array




    $post = Post::create($data);


    Session::flash('success', 'New Blog has been Published on Website for Particular Menu');

    return redirect()->back();

}

Create.blade.php

@extends ('layouts.app')

@section('content')

<!-- End Sidebar scroll-->
</aside>
<!-- ============================================================== -->
<!-- End Left Sidebar - style you can find in sidebar.scss  -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Page wrapper  -->
<!-- ============================================================== -->
<div class="page-wrapper">
    <!-- ============================================================== -->
    <!-- Container fluid  -->
    <!-- ============================================================== -->
    <div class="container-fluid">
        <!-- ============================================================== -->
        <!-- Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->

        <!-- ============================================================== -->
        <!-- End Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Start Page Content -->
        <!-- ============================================================== -->
        <!-- Row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header bg-info">
                        <div class="text-center">

                        </div>

                        @if(count($errors)>0)
                            <ul class="list-group">
                                @foreach($errors->all() as $error)
                                    <li class="list-group-item text-danger">
                                        {{$error}}
                                    </li>
                                @endforeach
                            </ul>
                        @endif

                            <div class="panel-heading">

                                <div class="text-center text-white">
                                    <b> <h2>Create a new Blog</h2></b>
                                </div>
                            </div><BR>
                            <div class="panel-body">
                                <form action="{{route('post.store')}}" method="post" enctype="multipart/form-data">
                                    {{csrf_field()}}


                                    <div class="form-group table-dark text-white">
                                        <label for ="category"><h3>Select a Menu</h3></label>
                                        <select name="category_id" id="category" class="form-control" >
                                            @foreach($levels as $category)
                                                <option value="{{$category->id}}">{{$category->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>





                                    <div class="form-group text-white">
                                        <label for ="title"><h3>Option1 date/Name Manually</h3></label>
                                        <input type="text" name="opt_1" class="form-control text-danger">
                                    </div>

                                    <div class="form-group text-white">
                                        <label for ="title"><h3>Option2 date/Name Manually</h3></label>
                                        <input type="text" name="opt_2" class="form-control text-danger">
                                    </div>

                                    <div class="form-group text-white">
                                        <label for ="title"><h3>Title</h3></label>
                                        <input type="text" name="title" class="form-control text-danger">
                                    </div>


                                    <div class="form-group text-white">
                                        <label for ="featured"><h3>Image/Featured</h3></label> <input type="file" name="featured" class="form-control">
                                    </div>

                                    <div class="form-group text_white">

                                        <label for ="file"><h3>PDF file</h3></label><input type="file" name="file" class="form-control">
                                    </div>




                                    <div class="form-group text-white" >
                                        <label for ="content"><h3>Content</h3></label>
                                        <textarea name="content" id="content" cols="5" rows="5" class="form-control"> </textarea>
                                    </div>

                                    <div class="form-group">
                                        <div class="text-center">
                                            <button class="btn btn-success" type="submit"> Submit Blog</button>
                                        </div>
                                   </div>
                                </form>
                            </div>
                    </div>


                        </div>
                        @stop

                        @section('styles')

                            <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.css" rel="stylesheet">

                        @stop

                        @section('scripts')

                            <script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.js"></script>


                            <script>
                                $(document).ready(function() {
                                    $('#content').summernote();
                                });

                            </script>
                        <!-- Row -->

                    javascript:
                    -------------
                    <script type="text/javascript">
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });

                        $(document).ready(function(){
                            $('#name').on('change',function(e){
                                console.log(e);
                                var parent_id= e.target.value;
                                $.getJSON('/your url/sub?parentID=' + parent_id, function(data){

                                    console.log(data);
                                    $('#sub_cat_id').empty();
                                    $.each(data,function(index, sub_cat_id){
                                        $('#sub_cat_id').append('<option value="'+sub_cat_id.id+'">'+sub_cat_id.name+'</option>');
                                    });
                                });

                            });
                        });
                    </script>


                    </div>
                </div>
            </div>
        </div>
        <!-- Row -->

@stop

Please suggest what I have to do to create the post for subcategory. thanks

04 Jun
2 weeks ago

me10071990 left a reply on Getting Submenu And Menu In All

I used $menu in my edit.blade.php s

                                                <select name="parent_id" id="parent_id">
                                                    <option value="0">edit</option>
                                                    @foreach($categories as $category)
                                                        <option value="{{$category->id}}" @if($category->id == $menu['parent_id'])

                                                        selected @endif>
                                                            {{$category->name}}</option>
                                                    @endforeach
                                                </select>

me10071990 left a reply on Getting Submenu And Menu In All

Thanks for your suggestion. Yes, in my database it contains top level items and nested children.

And now I am edited my code return view ('admin.categories.index')->withMenu($menu);

but nothing happned.

me10071990 left a reply on Getting Submenu And Menu In All

Thank you, @snapey ....I corrected it,

public function index()

{


    $menu= Category::with('children')->whereNull('parent_id')->get();


    return view ('admin.categories.index')->with($menu);


}

still getting same error

me10071990 left a reply on Getting Submenu And Menu In All

Thanks @bobbybouwmann , I am trying to add category and their subcategory on website, problem is that, all menu and sub-menu showing in one row. However, it should be shown like menu then sub-menu.

I create first 3 category:- 1 Home 2 Contact 3 People and I have added Good People and Bad people under Category People. But in my website all showing like 1 Home 2 Contact 3 People ->(under list)1 Good People 2Bad people then 4 Good People 5 Bad people

it's create.blade.php

{{csrf_field()}} Create New Menu @foreach($categories as $category) {{$category->name}} @endforeach
                                                <div class="text-center table-dark">
                                                    <label for ="Name" class="table-dark ">Name</label>
                                                </div>

                                                <input type="text" name="name" class="form-control">

                                            </div>

                                            <div class="form-group">
                                                <div class="text-center">
                                                    <button class="btn btn-success" type="submit">

                                                        Add Sub-Menu
                                                    </button>
                                                </div>
                                            </div>

                                        </form>

                                    </div>

CategoriesController

public function index()

{

       $menu= Category::with('children')->whereNull('parent_id')->get();


    return view ('admin.categories.index')->with('categories',$menu)->with('categories', Category::all());


}

public function store(Request $request) {

    // dd($request->all());
    $this->validate($request, [

        'name' =>'required',
        'parent_id' => 'required|numeric', //This will check the parent availability how about top level ? where id is 0?

    ]);

    Category::create([
        'name'=>$request->name,


        'parent_id'=>$request->parent_id
    ]);

    Session::flash('success', 'Category has created successfully');
    return redirect()->back();

}

index.blade.php

                                                <tr>


                                                <ul >
                                                    @foreach($categories as $category)
                                                <tr>
                                                        <td>
                                                        @if($category->children->count() >0 )
                                                           <li class="dropdown">
                                                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                                                    {{$category->name}}
                                                                    <b class="caret"></b></a>
                                                                <ul class="dropdown-menu">
                                                                    @foreach($category->children as $child)
                                                                        <li><a href="#">{{$child->name}}</a></li>
                                                                    @endforeach
                                                                </ul>
                                                            </li>
                                                        @else
                                                            <li><a href="">{{$category->name}}</a></li>
                                                        @endif

                                                        </td>

                                                   <td> <a href="{{route('category.edit', ['id' =>$category->id])}}" class="btn btn-sm btn-info">Edit</a>
                                                        <td>    <a href="{{route('category.delete', ['id' =>$category->id])}}" class="btn btn-sm btn-danger">Delete</a></td>
                                                    @endforeach

                                                </ul>

                                            </tr>

me10071990 started a new conversation Getting Submenu And Menu In All

When I am adding the category of subcategory it's has created with the help of parent_id but in my website it's showing like 1 home->1.1.-home1->1.2-home2 2 peole 3 contact and then (home 1 home 2) again repeat in category index and same adding in my localhost as it should be shown under home->home1 home2

31 May
2 weeks ago

me10071990 left a reply on Categories And Subcategories

I am entering name of subcategories and it's nothing showing in my website

me10071990 left a reply on Categories And Subcategories

I tried with code for my subategory

@extends('layouts.app')

@section('content')

<!-- End Sidebar scroll-->
</aside>
<!-- ============================================================== -->
<!-- End Left Sidebar - style you can find in sidebar.scss  -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Page wrapper  -->
<!-- ============================================================== -->
<div class="page-wrapper">
    <!-- ============================================================== -->
    <!-- Container fluid  -->
    <!-- ============================================================== -->
    <div class="container-fluid">
        <!-- ============================================================== -->
        <!-- Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->

        <!-- ============================================================== -->
        <!-- End Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Start Page Content -->
        <!-- ============================================================== -->
        <!-- Row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header bg-info">
                        <div class="text-center">
                            <h4 class="m-b-0 text-white">


                                <div class="panel panel-default">
                                    <div class="panel-heading" >
                                        <div class="text-center">

                                            <b>Create new Sub-Menu</b>
                                        </div>
                                    </div>

                                    <div class="panel-body">
                                        <form action="{{route('Subcategories.store')}}" method="post">
                                            {{csrf_field()}}
                                            <div class="form-group">


                                                <div class="form-group table-dark text-white">
                                                    <label for ="category"><h3>Select a Menu</h3></label>
                                                    <select name="category_id" id="category" class="form-control" >
                                                        @foreach($categories as $category)
                                                            <option value="{{$category->id}}">{{$category->name}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>

                                                <div class="text-center table-dark">
                                                    <label for ="Name" class="table-dark ">Name</label>
                                                </div>

                                                <input type="text" name="sub_cat_name" class="form-control">

                                            </div>

                                            <div class="form-group">
                                                <div class="text-center">
                                                    <button class="btn btn-success" type="submit">

                                                        Add Sub-Menu
                                                    </button>
                                                </div>
                                            </div>

                                        </form>

                                    </div>
                                </div>


                            </h4>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Row -->

@stop

me10071990 left a reply on Categories And Subcategories

I am trying to make subcategories under categories, like I have 4 categories 1.home 2. about 3. people 4 contact us and now I want to show like people->people1 , people 2 .

me10071990 started a new conversation Categories And Subcategories

Hey!

I'm editing a my website on local host and I have a db table called categories which has the following fields:

id parent_id name

My model looks like

public function children() {
    return $this->hasMany(Category::class, 'parent_id', 'id');
}

public function parent()
{
    return $this->belongsTo(Category::class, 'parent_id');
}

and my controller looks

public function store(Request $request) {

    $this->validate($request, [

        'name' =>'required'

    ]);




    $category= new Category;

    $category= Category::with('children')->whereNull('parent_id')->get();
    
    $category->name =$request->name;

    $category->save();

}

and my create.blade.php for category

@extends('layouts.app')

@section('content')

<!-- End Sidebar scroll-->
</aside>
<!-- ============================================================== -->
<!-- End Left Sidebar - style you can find in sidebar.scss  -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Page wrapper  -->
<!-- ============================================================== -->
<div class="page-wrapper">
    <!-- ============================================================== -->
    <!-- Container fluid  -->
    <!-- ============================================================== -->
    <div class="container-fluid">
        <!-- ============================================================== -->
        <!-- Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->

        <!-- ============================================================== -->
        <!-- End Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Start Page Content -->
        <!-- ============================================================== -->
        <!-- Row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header bg-info">
                        <div class="text-center">
                            <h4 class="m-b-0 text-white">


                                <div class="panel panel-default">
                                    <div class="panel-heading" >
                                        <div class="text-center">

                                            <b>Create new Menu</b>
                                        </div>
                                    </div>

                                    <div class="panel-body">
                                        <form action="{{route('category.store')}}" method="post">
                                            {{csrf_field()}}
                                            <div class="form-group">

                                                <div class="text-center table-dark">
                                                    <label for ="Name" class="table-dark ">Name</label>


                                                </div>

                                                <input type="text" name="name" class="form-control">

                                            </div>

                                            <div class="form-group">
                                                <div class="text-center">
                                                    <button class="btn btn-success" type="submit">

                                                        Add Menu
                                                    </button>
                                                </div>
                                            </div>

                                        </form>

                                    </div>
                                </div>


                            </h4>
                        </div>
            </div>
        </div>
            </div>
        </div>
    </div>
</div>

        <!-- Row -->

@stop

I'm not really sure of the best way of achieving this and hoping someone can help point me in the right direction :-)

28 May
3 weeks ago

me10071990 started a new conversation I Want To Add Subcategories In My Category Dynamically

Hi everyone,

I made a form in which I have titlte, image, pdf, content and category and all are working fine, but I want to add submenu in my form and also want to make this dynamic so can show all submenu on my website.

Thank you to all

me10071990 left a reply on Make A Hierarchical Structure For Instances Of A Model In Laravel

Hi everyone,

I made a form in which I have titlte, image, pdf, content and category and all are working fine, but I want to add submenu in my form and also want to make this dynamic so can show all submenu on my website.

Thank you to all

27 May
3 weeks ago

me10071990 left a reply on I Am Able To Add The Value In Both (cat And Subcat) But On My Website Only Menu Showing How Can Make Submenu Of Menu

Category.php

public function Category()
{
    return $this->belongsTo('App\Category','sub_cat_id');
}

public function subCategory()
{
    return $this->hasMany('App\Category','sub_cat_id');

}

me10071990 left a reply on I Am Able To Add The Value In Both (cat And Subcat) But On My Website Only Menu Showing How Can Make Submenu Of Menu

@devfrey so sorry ..

Let me correct it..

class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];

public function category()

{ return $this->belongsTo('App\Category'); } }

Category Model

public function subCategory() { return $this->hasMany('App\Category','sub_cat_id');

}

public function Category() { return $this->belongsTo('App\Category','sub_cat_id'); }

Controller

public function store(Request $request) {

$this->validate($request, [

    'name' =>'required'

]);

$category= new Category;

$category->name =$request->name;

$category->save();

Session::flash('success', 'Category has created successfully');
return redirect()->back();

me10071990 started a new conversation I Am Trying To Open Pdf File That I Have Uploaded And When Click On Website It's Showing File Not Found 404 –

View

                                    <div class="entry-content">

                                        <a  target="_blank" href="{{$post->file}}"><p style="font-size: 18px;color: #468b10;">   {{ $post->content }}</p></a>

                                    </div>

Controller.. if (request('file')) { $file = request('file'); $file=$file_name::get($file); $file_name = time() . $file->getClientOriginalName(); $file->move('uploads/posts', $file_name); $data['file'] = 'uploads/posts/'.$file_name; }

me10071990 left a reply on I Am Able To Add The Value In Both (cat And Subcat) But On My Website Only Menu Showing How Can Make Submenu Of Menu

Controller(Sub category)

public function store(Request $request) { $this->validate($request, [

        'sub_cat_name' =>'required',
        'sub_cat_id' => 'required'


    ]);

    $data=[

        'sub_cat_id'=>$request->sub_cat_id,
        'sub_cat_name'=>$request->sub_cat_name,
   ];

    $subcategory=Subcategory::create($data);
    Session::flash('success', 'Subcategory has created successfully');

    return redirect()->back();

}

Controller(Category)

public function store(Request $request) {

    $this->validate($request, [

        'name' =>'required'

    ]);

    $category= new Category;

    $category->name =$request->name;

    $category->save();

    Session::flash('success', 'Category has created successfully');
    return redirect()->back();

}

Category Model

public function subCategory()
{
    return $this->hasMany('App\Category','sub_cat_id');

}

public function Category()
{
    return $this->belongsTo('App\Category','sub_cat_id');
}

subCategory model

class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];

public function category()

{
    return $this->belongsTo('App\Category');
}

}

me10071990 left a reply on I Am Able To Add The Value In Both (cat And Subcat) But On My Website Only Menu Showing How Can Make Submenu Of Menu

Category model

public function subCategory() { return $this->hasMany('App\Category','sub_cat_id');

}

public function Category() { return $this->belongsTo('App\Category','sub_cat_id'); } class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];

public function category()

{ return $this->belongsTo('App\Category'); } }

me10071990 started a new conversation I Am Able To Add The Value In Both (cat And Subcat) But On My Website Only Menu Showing How Can Make Submenu Of Menu

I made a menu dynamically and trying to make sub-menu but getting nothing happend

here is Category model

public function subCategory() { return $this->hasMany('App\Category','sub_cat_id');

}

public function Category() { return $this->belongsTo('App\Category','sub_cat_id'); } class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];

public function category()

{ return $this->belongsTo('App\Category'); } } and route is

route::post('/Subcategory/store',[

'uses'=>"[email protected]",
'as'=>'Subcategories.store',

]);

route::get('/subcategory/edit/{id}',

[
    'uses'=>"[email protected]",

    'as'=>'Subcategories.edit',
]);

route::post('/subcategory/update/{id}',

[
    'uses'=>"[email protected]",

    'as'=>'Subcategories.update',
]); 

And Controller for Subcateogry is public function store(Request $request) { $this->validate($request, [

    'sub_cat_name' =>'required',
    'sub_cat_id' => 'required'


]);

$data=[

    'sub_cat_id'=>$request->sub_cat_id,
    'sub_cat_name'=>$request->sub_cat_name,

];

$subcategory=Subcategory::create($data);
Session::flash('success', 'Subcategory has created successfully');

return redirect()->back();

} and Controller for Category

public function store(Request $request) {

$this->validate($request, [

    'name' =>'required'

]);

$category= new Category;

$category->name =$request->name;

$category->save();

Session::flash('success', 'Category has created successfully');
return redirect()->back();

}

and only I am able to add the value in both (cat and subcat) but on my website only menu showing how can make submenu of menu

me10071990 left a reply on How To Create Model For Category Subcategory And Product

I made a menu dynamically and trying to make sub-menu but getting nothing happend

here is Category model

public function subCategory()
{
    return $this->hasMany('App\Category','sub_cat_id');

}

public function Category()
{
    return $this->belongsTo('App\Category','sub_cat_id');
}

class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];

public function category()

{
    return $this->belongsTo('App\Category');
}

} and route is

route::post('/Subcategory/store',[

    'uses'=>"[email protected]",
    'as'=>'Subcategories.store',

]);

route::get('/subcategory/edit/{id}',

    [
        'uses'=>"[email protected]",

        'as'=>'Subcategories.edit',
    ]);

route::post('/subcategory/update/{id}',

    [
        'uses'=>"[email protected]",

        'as'=>'Subcategories.update',
    ]); 

And Controller for Subcateogry is public function store(Request $request) { $this->validate($request, [

        'sub_cat_name' =>'required',
        'sub_cat_id' => 'required'


    ]);

    $data=[

        'sub_cat_id'=>$request->sub_cat_id,
        'sub_cat_name'=>$request->sub_cat_name,
   ];

    $subcategory=Subcategory::create($data);
    Session::flash('success', 'Subcategory has created successfully');

    return redirect()->back();

}

and Controller for Category

public function store(Request $request) {

    $this->validate($request, [

        'name' =>'required'

    ]);

    $category= new Category;

    $category->name =$request->name;

    $category->save();

    Session::flash('success', 'Category has created successfully');
    return redirect()->back();

}

and only I am able to add the value in both (cat and subcat) but on my website only menu showing how can make submenu of menu

26 Apr
1 month ago

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

So sorry for that @snapey , I tried with many possible way, and it will work

25 Apr
1 month ago

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

Ok , so I have to make every new blade.php for each category ?

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

Ok thank you , what code I need to change after that

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

I put from phpmyadmin as a null and its working now however designed is still not going through...

public function show(Category $category) {

return view( 'categories.' . $category->template, compact('category'));

} after this what code I have to make or change.. thank you

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

now in data base it's showing error.."SQLSTATE[HY000]: General error: 1364 Field 'template' doesn't have a default value (SQL: insert into categories (name, updated_at, created_at) values (HOME, 2019-04-25 12:42:37, 2019-04-25 12:42:37)) ◀"

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

Thank you @snapey -:) I am using this in CategoriesController public function show(Category $category) {

    return view( 'categories.' . $category->template, compact('category'));

} 

so what I have to do next

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

public function show(Category $category) {

    $template = 'categories/'. $category->template . '.blade.php';
    return view($template, compact('category'));


}

I did this and also changed in <?php

use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;

class CreateCategoriesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id');

        $table->string('name');
       $table->string('template');
        $table->timestamps();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::dropIfExists('categories');
}

} and what is next step

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

@SNAPEY - What I have to then, Can I use if else statement...@Snapey... thank you for your guidance

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

@MAGED - Thank you, I will try and let you know @maged . :)

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

is this not commented out, I was just checking another code for it and also using if elseif condition, please help me to correct so I can do and learn in best way... thank you very much

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

public function show($id) {

   // $category= new Category;
    //$template = 'categories/'. $category->template . '.blade.php';
    //return view($template, compact('category'));


}

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

I have send already pasted all the code please check

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

Thanks @maged , I am doing this as you told still it's nothing happend

public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id');

        $table->string('name');
        $table->string('template');
        $table->timestamps();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::dropIfExists('categories');
}

}

and

my categoriesConroller

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

ok @snapey , first I have made 4 category in my admin Home, Contact, About, Porduct and these are showing on menu list in website.

However, I have made a a single template category.blade,php as a designed for every category will have same designed.

And I want to create a different layout designed for each menu individual..

I am pasting all code below...

This is header.blade.php

image
                <div class="btn-menu">
                    <span></span>
                </div><!-- //mobile menu button -->
            </div><!-- /wrap-search -->

            <div class="wrap-nav">
                <nav id="mainnav" class="mainnav">
                    <ul class="menu">

                  @foreach($categories as $category)
                            <li class="text-black-50"><a href="/category/{{$category->id}}">{{$category->name}}</a></li>
                  @endforeach

                    </ul>
                </nav>

            </div><!-- /wrap-nav -->
        </div><!-- /col-md-12 -->
    </div><!-- /row -->
</div><!-- /container -->

this is frontend controller

me10071990 left a reply on What Is Best Way To Make Every Category Page With New Designed

Still I am doing the same but its nothing happend,