Sozyar

Sozyar

Member Since 1 Month Ago

Experience Points
630
Total
Experience

4,370 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 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 1
630 XP
May
21
1 week ago
Activity icon

Replied to Illuminate \ Http \ Exceptions \ PostTooLargeException No Message

PostController.php

 <?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;
use Auth;
use DB;
use App\Post;
use App\Category;
use App\Subcategory;
use Image; 

class PostController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $page_name = 'Posts';   
        if (Auth::user()->type === 1 || Auth::user()->hasRole('Editor') || Auth::user()->hasRole('Master Admin')) { 
           $data = Post::with(['creator'])->orderBy('id','DESC')->get(); 
        }else{
            $data = Post::with(['creator'])->where('created_by', Auth::user()->id)->orderBy('id','DESC')->get();
        }
        return view('admin.post.list',compact('data','page_name'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
         $page_name = 'Create Post';
        $categories = Category::where('status',1)->select('name','id')->get(); 
        return view('admin.post.create',compact('page_name','categories'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request) //with this request we can pass the title , slug ... all fields
    {
        $this->validate($request,[
          'title'=>'required',
          'short_description'=>'required', 
          'description'=>'required', 
          'category_id'=>'required',
          'subcategory_id'=>'required',
          'img'=>'required',  
      ],[

        'title.required' => "The Title Field is Required",
        'short_description.required' => "The Short Description Field is Required",
        'description.required' => "The Description Field is Required",
        'img.required' => "The Image Field is Required",
        ]);

     $post = new Post();  // using Post Model to all the below fields can connect with Post Table in database
     $post->title = $request->title;
     $post->slug = str_slug($request->title,'-'); //title will be updated with this title name separated with -
     $post->short_description = $request->short_description;
     $post->description = $request->description;
     $post->category_id = $request->category_id;
     $post->subcategory_id = $request->subcategory_id;
     $post->status = 1;
     $post->hot_news = 0;
     $post->view_count = 0;
     $post->main_image = '';
     $post->thumb_image = '';
     $post->list_image = '';
     $post->created_by = Auth::id(); //who created this post brings by ID
     $post->save();
     $file = $request->file('img');
     $extension = $file->getClientOriginalExtension(); 
     $main_image = 'post_main_'.$post->id.'.'.$extension; 
     $thumb_image = 'post_thumb_'.$post->id.'.'.$extension; 
     $list_image = 'post_list_'.$post->id.'.'.$extension;
     Image::make($file)->resize(653,569)->save(public_path('/post/'.$main_image)); 
     Image::make($file)->resize(360,309)->save(public_path('/post/'.$list_image));
     Image::make($file)->resize(122,122)->save(public_path('/post/'.$thumb_image));
     $post->main_image = $main_image; 
     $post->thumb_image = $thumb_image;
     $post->list_image =  $list_image;
     $post->save();
     return redirect()->action('Admin\[email protected]')->with('success','Post Created Successfully');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $page_name = 'Edit Post';
        $post = Post::find($id);
        $categories = Category::where('status',1)->select('name','id')->get(); 
        return view('admin.post.edit',compact('page_name','post','categories'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
         $this->validate($request,[
          'title'=>'required',
          'short_description'=>'required', 
          'description'=>'required', 
          'category_id'=>'required',
          'subcategory_id'=>'required',

        ],[

        'title.required' => "The Title Field is Required",
        'short_description.required' => "The Short Description Field is Required",
        'description.required' => "The Description Field is Required",
        'img.required' => "The Image Field is Required",
        ]);

     $post = Post::find($id);
    if($request->file('img')){
        @unlink(public_path('/post/'.$post->$main_image)); 
        @unlink(public_path('/post/'.$post->$thumb_image));
        @unlink(public_path('/post/'.$post->$list_image));
        $file = $request->file('img');
     $extension = $file->getClientOriginalExtension();
     $main_image = 'post_main_'.$post->id.'.'.$extension;
     $thumb_image = 'post_thumb_'.$post->id.'.'.$extension;
     $list_image = 'post_list_'.$post->id.'.'.$extension; 
     Image::make($file)->resize(653,569)->save(public_path('/post/'.$main_image));
     Image::make($file)->resize(360,309)->save(public_path('/post/'.$list_image));
     Image::make($file)->resize(122,122)->save(public_path('/post/'.$thumb_image));
     $post->main_image = $main_image;
     $post->thumb_image = $thumb_image;
     $post->list_image =  $list_image;
   }
     $post->title = $request->title;
     $post->slug = str_slug($request->title,'-');
     $post->short_description = $request->short_description;
     $post->description = $request->description;
     $post->category_id = $request->category_id;
     $post->subcategory_id = $request->subcategory_id;
     $post->save();
     return redirect()->action('Admin\[email protected]')->with('success','Post Updated Successfully');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $post = Post::find($id);
        @unlink(public_path('/post/'.$post->$main_image));
        @unlink(public_path('/post/'.$post->$thumb_image));
        @unlink(public_path('/post/'.$post->$list_image));
        $post->delete();
        return redirect()->action('Admin\[email protected]')->with('success','Post Deleted Successfully');
    }



     public function status($id){
       $post = Post::find($id);
       if ($post->status === 1) {
            $post->status = 0;
        }else{
             $post->status = 1;
        }
          $post->save();
          return redirect()->action('Admin\[email protected]')->with('success','Post Status Changed Successfully');
    }


     public function hot_news($id){
       $post = Post::find($id);
       if ($post->hot_news === 1) { 
            $post->hot_news = 0;
        }else{
             $post->hot_news = 1;
        }
          $post->save();
          return redirect()->action('Admin\[email protected]')->with('success','Post Set As Hot News Changed Successfully');
    }


 public function subcategories()
    {

       $category_id = Input::get('category_id');
      $subcategories = Subcategory::where('category_id', '=', $category_id)->where('status',1)->get();
      return response()->json($subcategories);
    }

}

Activity icon

Replied to Illuminate \ Http \ Exceptions \ PostTooLargeException No Message

Ok , but i want to let me to add video , how to do it ?

May
20
1 week ago
Activity icon

Replied to Illuminate \ Http \ Exceptions \ PostTooLargeException No Message

Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files.

May
19
2 weeks ago
Activity icon

Started a new Conversation Illuminate \ Http \ Exceptions \ PostTooLargeException No Message

I want to add video on my post while it was uploading this error occur please help

Activity icon

Replied to How To Arrange Picture 3*3

Thank you !

Activity icon

Replied to Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

It's not solution i can check the weather with 1&0 that refers to is it hot news or not

Activity icon

Replied to Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

$hot_news = Post::with('creator')->withCount('comments')->where('hot_news',1)->where('status',1)->orderBy('id','DESC')->first();

Activity icon

Replied to Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

Giving Error

Call to a member function count() on null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

Activity icon

Started a new Conversation Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

I have hot news button to make posts as a hot news when i make a post as a hot news it works fine but when i don't have any hot news post it will give this error . laravel 5.8

<div class="feature_article_inner">
                        <div class="tag_lg red"><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}">Hot News</a></div>
                        <div class="feature_article_title">
                            <h1><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}" target="_self">{{ $hot_news['title'] }} </a></h1>
                        </div>
                         <!-- feature_article_title -->

 <div class="feature_article_date">
    by: <a href="{{ url('/author') }}/{{ $hot_news['creator']['id'] }}" >{{ $hot_news['creator']['name'] }}</a> ,
       &nbsp;{{$hot_news['created_at']->diffForHumans() }}           </a></div>
                        <!-- feature_article_date -->

                       <div style="font-size: 9.5pt; color: black; "> Views: {{ $hot_news['view_count'] }} </div>

                        <div class="feature_article_content">
                           {{ $hot_news['short_description'] }}
                        </div>
                        <!-- feature_article_content -->

                        <div class="article_social">
                             
                            <span><i class="fas fa-comment"></i><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}">{{ $hot_news['comments_count'] }} Comments </a></span>
                        </div>
                        <!-- article_social -->

                    </div>
May
13
2 weeks ago
Activity icon

Started a new Conversation How To Arrange Picture 3*3

In post table i have posts with title image etc... now it will arrange like list means vertically , i just want to get posts and arrange them 3*3 means arrange 3 pictures horizontally then go to next line how to do it please help?

footer.blade.php

  <div class="col-md-3" style=" margin-left: 192px ">
                <div class="footer_widget_title">
                    <h3><a target="_self">Tech Photos</a></h3>
                </div>
                @foreach($shareData['posts'] as $item)
                <div class="widget_photos">
                    
                    <a href="{{ url('/details') }}/{{ $item->slug }}" ><img class="img-responsive"
                     src="{{ asset('post') }}/{{ $item->thumb_image }} " alt="{{ $item->title }}">
                    </a>
                </div>@endforeach

            </div>

AppServiceProvider.php

$shareData = array(
$posts = Post::where('status',1)->limit(5)->get();
'posts'=>$posts
);
view()->share('shareData',$shareData);
May
07
3 weeks ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

If you understand by checking my project you may solve this easily

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

Dear i have used permission and roles package , when you feel free just come to my pc using teamviewer to show you my project it will be very much clear to understand

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

this was your code

public function authenticated(Request $request, $user) { $role = $user->role; if ($role === 'admin') { return redirect('pet/admin'); } if ($role === 'bkeep') { return redirect('account/index'); } return redirect('pet/index'); }

it seems you have role filed in users table that means you can distinguish users by role

in my case i have type field in users table instead of role field

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

I have tested this below code in AuthenticatesUser.php

protected function authenticated(Request $request, $user) { $type = $user->type; if ($type === 1) { return redirect('/back/permission'); } if ($type === 2) { return redirect('/back'); } return redirect('/login'); }

it works well but it uses to redirect me after logged in

i just want something like validate to prevent users to login by type

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

As i said i'm new to laravel , i don't know about traits

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

This is default LoginController.php


<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/back'; // redirect to back page

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}


Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

it seems configured auth not Taylor's original auth so confused

May
06
3 weeks ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

can i add public function authenticated method to regular login controller like your upper example for admin and users ?

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

Yeah I am new to laravel , but it's clear what i want admin should login from admin login and others should login from users login after logged in for all users should redirect to same admin panel and also i have putted all codes here asked that how to modify the code i got the idea about that but don't know how to code

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

if not , can you come to my pc to check codes using remote controller ?

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

I have putted all the codes please check it and modify it then write the modified codes here

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

This is AdminLoginController where should write code


<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;

class AdminLoginController extends Controller
{

	public function __construct()
	{

		$this->middleware('guest')->except('logout'); //who want to have access to this  // before //$this->middleware('guest:admin');

	}


    public function showLoginForm()
    {


    	return view('auth.admin-login');

    }


    public function login(Request $request)
    {
    	// Validate the form data
    	 $this->validate($request, [
        'email'   => 'required|email',
        'password' => 'required|string|min:6'
      ]);

    	// Attemp to log the user in
    	 if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
        // if successful, then redirect to their intended location
        return redirect()->intended(route('admins')); // we redirected them where they wanted to go  // admin.dashboard  // route('admins'); should be same with ->name('admins'); in page of web 
      }
    	

    	// If unsuccessful, then redirect back to the login with the form data
    	return redirect()->back()->withInput($request->only('email', 'remember'));
    }


}

May
05
4 weeks ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

I have checked you have distinguished users by role , but what i did i have distinguished users by type in users table only admin has" type 1 " others have "type 2" i don't know how to code ?

Apr
25
1 month ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

can you come to my pc with anydesk to check it please ??

Apr
24
1 month ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

I did and it works but all user roles can login from both login page how to make it one login particular to admin role other roles could not login from admin login please answer clearly it's very important to me

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

How can use users table for this blade ? This is admin-login.blade

@include('layouts.app')


    <div class="sufee-login d-flex align-content-center flex-wrap">
        <div class="container">
           
                
            
            <div class="login-content">
                <div class="login-logo">
                    <a href="{{ route('login') }}">
                        <img class="align-content" src="{{ asset('others') }}/{{  $shareData['admin_logo'] }}" alt="">
                    </a><div style="color: white; text-align: center;">Admin Login</div>
                </div>
                <div class="login-form">
                    <form class="form-horizontal" method="POST" action="{{ route('admin.login.submit') }}">
                        {{ csrf_field() }} <!-- means you are still using middleware-->
                        <div class="form-group">
                            <label>Email address</label>
                            
                             <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                        </div>
                        <div class="form-group">
                            <label>Password</label>
                            <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                        </div>
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
                            </label>
                            <label class="pull-right">
                                <a class="btn btn-link" href="{{ route('password.request') }}">
                                    Forgot Your Password?
                                </a>
                            </label>

                        </div>
                        <button type="submit" name="login" class="btn btn-success btn-flat m-b-30 m-t-30">Sign in</button>
                        <div class="register-link m-t-15 text-center">
                             <br>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>


    <script src="{{ asset('admin/assets/js/vendor/jquery-2.1.4.min.js') }}"></script>
    <script src="{{ asset('admin/assets/js/popper.min.js') }}"></script>
    <script src="{{ asset('admin/assets/js/plugins.js') }}"></script>
    <script src="{{ asset('admin/assets/js/main.js') }}"></script>


</body>
</html>


Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

i want after logged in for admin , editor and blogger for all users redirect me to admin panel , only different login from should have

Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

in users table i have admin , editor and blogger i want admin can login from different page than editor and blogger login page all users exist in users table but blogger or editor shouldn't login from admin login page and same for admin too how can make this please help .

Apr
23
1 month ago
Activity icon

Replied to Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

if not can i make admin that can login on different page just two login page form user table how can i do it ?

Activity icon

Started a new Conversation Redirect-admin-to-back-admin-panel-after-login-in-laravel-5-8

I have configured auth to multi auth one is users table and another one is admins table and i did some changes both of tables have their own login separately when i logged in on user login page then will redirect me to admin panel the path is /back and i want for both case admin and user login should redirect me to admin panel same path means after logged in on admin login page redirect me to admin panel to same /back path please help.

web.php


Route::group(['prefix'=>'back','middleware'=>'auth'],function(){
        Route::get('/', 'Admin\[email protected]');
});

Auth::routes();

Route::get('/home', '[email protected]')->name('home');

Route::prefix('admins')->group(function() {


Route::get('/login', 'Auth\[email protected]')->name('admins.login');

Route::post('/login', 'Auth\[email protected]')->name('admin.login.submit');

Route::get('/', '[email protected]')->name('admins');

});

Auth/AdminLoginController.php


<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;

class AdminLoginController extends Controller
{

    public function __construct()
    {

        $this->middleware('guest:admin'); 

    }


    public function showLoginForm()
    {


        return view('auth.admin-login');

    }


    public function login(Request $request)
    {

         $this->validate($request, [
        'email'   => 'required|email',
        'password' => 'required|string|min:6'
      ]);


         if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {

        return redirect()->intended(route('admins')); 
      }



        return redirect()->back()->withInput($request->only('email', 'remember'));
    }


}


Apr
10
1 month ago
Activity icon

Started a new Conversation Laravel 5.8 Dynamic Dependant Select Dropdowns

I want to get subcategories of current category using JQuery Ajax for creating posts. It doesn't work for me but when i change the URL on browser like this http://127.0.0.1:8000/back/posts/create/json-subcategories?category_id=1 it brings all subcategory in an array

Route Page:


Route::get('/posts/create', ['uses'=>'Admin\[email protected]','as'=>'post-create', 'middleware'=> 'permission:Post List|All'] );

Route::get('/posts/create/json-subcategories', ['uses'=>'Admin\[email protected]','as'=>'post-create', 'middleware'=> 'permission:Post List|All'] );

PostController:


 public function create()
    {
         $page_name = 'Create Post';
        $categories = Category::where('status',1)->pluck('name','id'); 
        return view('admin.post.create',compact('page_name','categories'));
    }



public function subcategories()
    {

       $category_id = Input::get('category_id');
      $subcategories = Subcategory::where('category_id', '=', $category_id)->get();
      return response()->json($subcategories);
    }

create.blade.php


<div class="form-group">
            <label for="">Your Category</label>
            <select class="form-control" name="categories" id="categories">
              <option value="0" disable="true" selected="true">=== Select Category ===</option>
                @foreach ($categories as $key => $value)
                  <option value="{{$value}}">{{ $value }}</option>
                @endforeach
            </select>
          </div>



          <div class="form-group">
            <label for="">Your Subcategory</label>
            <select class="form-control" name="subcategories" id="subcategories">
              <option value="0" disable="true" selected="true">=== Select Subcategory ===</option>
            </select>
          </div>



<script src="{{asset('js/jquery.js')}}"></script>
<script type="text/javascript">

$('#categories').on('change', function(e){
        console.log(e);

  var category_id = e.target.value;
        $.get('/posts/create/json-subcategories?category_id=' + category_id,function(data) {
          console.log(data);
      $('#subcategories').empty();
          $('#subcategories').append('<option value="0" disable="true" selected="true">=== Select Subcategory ===</option>');

$.each(data, function(index, subcategoriesObj){
            $('#subcategories').append('<option value="'+ subcategoriesObj.id +'">'+ subcategoriesObj.name +'</option>');
          })
Apr
05
1 month ago
Activity icon

Started a new Conversation I Want To Get Subcategories Of Current Category For Creating Posts

I want to get subcategories of current category for creating posts