Flex

Flex

Member Since 2 Years Ago

Experience Points 10,420
Experience
Level
Lessons Completed 7
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

19 Jan
1 day ago

Flex left a reply on How Can Print Data On Table Related To Login User?

@vilfago how can set one to one relationship? may I use relationship on both models Student and User

Flex left a reply on How Can Print Data On Table Related To Login User?

@vilfago No any error yes logged user filled his/her data

Flex started a new conversation How Can Print Data On Table Related To Login User?

Hi, I have following table like students


id  name  email                 telephone         user_id
 1  anne   [email protected]   07115550096         5

user_id is related to id of users table.

now I need print all name, email and telephone data witch related to login user id. I have following controller function for that

public function index()
    {
        $students = Student::personal()->get();
        return view('students.index')->withStudents($students);
    }

and Student Model

 public function scopePersonal($query)
{
     return $query->where('user_id', Auth::user()->id);
      
}

using above syntax I am printing data as following,

{{Auth::user()->name}}
{{Auth::user()->email}}
{{Auth::user()->telephone}}

but it is not printing telephone value

18 Jan
2 days ago

Flex left a reply on What Is RESTFUL API?

@hdsavani I did your tutorials. but when I test

GET, URL:http://localhost:8000/oauth/token

it is get following error msg There was an error connecting to GET,%20URL:http://localhost:8000/oauth/token.

what is the problem? may I should insert data to tables?

15 Jan
5 days ago

Flex left a reply on How To Add Laravel Project To Github?

I got this error please make sure you have correct access right

Flex left a reply on How To Add Laravel Project To Github?

@manelgavalda may I use cmd after install git?

Flex started a new conversation How To Add Laravel Project To Github?

I am very new to github. now I have created new account in github. then, Please guide me how can I add My Laravel project on new repository in github?

10 Jan
1 week ago

Flex started a new conversation What Are The Differents Between RESTful And SOAP Based Web Services?

what are the differents between RESTful and SOAP based web services? give some examples?

09 Jan
1 week ago

Flex left a reply on What Is RESTFUL API?

@sergiu17 @schemeza Then what is JWT and witch is relationship with restfull api and web services?

Flex started a new conversation What Is RESTFUL API?

hello, I need to understand what is restful api and , important of apis and some examples of restful api. and some body know good tutorials links how to develop restful apis using laravel please post links here.

Thanks.

22 Dec
4 weeks ago

Flex started a new conversation 1/1) BadMethodCallException Method [validator] Does Not Exist.

using laravel 5.6 and in my controller I have following code,

$input = $request->all();
        $validator = $this->validator($input);

        if ($validator->passes()){
            $booking = $this->create($input)->toArray();
            $booking['link'] = str_random(30);

            DB::table('activations')->insert(['id_user' => $booking['id'], 'token' => $booking['link']]);
            Mail::send('mail.activation', $booking, function($message) use ($booking) {
                $message->to($booking['email']);

                $message->subject('acxian.com - Activation Code');
            });

but when I try submit button following error is occurring,

1/1) BadMethodCallException

Method [validator] does not exist.

how can I fix this?

14 Dec
1 month ago

Flex started a new conversation How Can Count Table Column Unique Values In Laravel 5.6?

working with laravel 5.6 and mysql. I have following table name as projects

id  name    type  
1   tuna        bio
2   nhye    IT
3   hyuj        bio
4   tour        IT
5   ghyt        commerce

I need count type column values which are unique values. as an example in above table I need count values 3 because there are three different values like bio, IT and commerce. how can I do this?

04 Dec
1 month ago

Flex left a reply on Why Did Not Update Category Name And Image In Laravel?

@munazzil when I use route:list I can see only

App\Http\Controllers\[email protected]

with

GET|HEAD

Flex left a reply on Why Did Not Update Category Name And Image In Laravel?

@realrandyallen clear it but still not success here

03 Dec
1 month ago

Flex left a reply on Why Did Not Update Category Name And Image In Laravel?

@realrandyallen did it same thing here when I update some thing here my url will like this

http://localhost:8000/category/update/19?_method=put&description=boatmk&image=&remove=0    //boatmk is updated category name

Flex started a new conversation Why Did Not Update Category Name And Image In Laravel?

working with Laravel 5.6 and MySQL. I am going to update categoryname and image in my categories table using the following controller function?

public function update(Request $request, $id)
{

    if ($request->isMethod('get'))
        return view('categories.form', ['image' => Category::find($id)]);

    else {
        $rules = [
            'categoryname' => 'required',
        ];
        $this->validate($request, $rules);
        $image = Category::find($id);
        if ($request->hasFile('image')) {
            $dir = 'images/';
            if ($image->image != '' && File::exists($dir . $image->image))
                File::delete($dir . $image->image);
            $extension = strtolower($request->file('image')->getClientOriginalExtension());
            $fileName = str_random() . '.' . $extension;
            $request->file('image')->move($dir, $fileName);
            $image->categoryimage = $fileName;
        } elseif ($request->remove == 1 && File::exists('images/' . $image->image)) {
            File::delete('images/' . $image->post_image);
            $image->categoryimage = null;
        }
    }
    $image->categoryname = $request->description;
    $image->save();
    return redirect()->route('categories.index');
}

and route

Route::match(['get', 'put'], 'category/update/{id}', '[email protected]');

and edit form

@if(isset($image))
        <form method="PUT" action="http://localhost:8000/category/update/{{$image->id}}" enctype="multipart/form-data">

        <input type="hidden" name="_method" value="put">

<label for="description" class="col-form-label col-md-3 col-lg-2">Description</label>
                <div class="col-md-8">
                    <input class="form-control" autofocus placeholder="Description" name="description" type="text" id="description" value="{{ isset($image) ? $image->categoryname : '' }}">



 <label for="image" class="col-form-label col-md-3">Image</label>
                    <div class="col-md-5">
                        <img id="preview"
                             src="{{asset((isset($image) && $image->categoryimage!='')?'images/'.$image->categoryimage:'images/noimage.png')}}"
                             height="200px" width="200px"/>
                        <input class="form-control" style="display:none" name="image" type="file" id="image" name="_token" value="{{ csrf_token() }}">
                        <br/>
                        <a href="javascript:changeProfile();">Add Image</a> |
                        <a style="color: red" href="javascript:removeImage()">Remove</a>
                        <input type="hidden" style="display: none" value="0" name="remove" id="remove">

but when I try to update data it is not updating. only refresh to the same page. no, any error. how can I fix this problem?

Flex left a reply on Why Did Not Update Category Name And Image In Laravel?

can you any one tell me how can I put my $image variable id in my form action

http://localhost:8000/update/{id}

Flex left a reply on Why Did Not Update Category Name And Image In Laravel?

@sumbria it is not sucess it is change my edit form to new category post page

Flex started a new conversation Why Did Not Update Category Name And Image In Laravel?

I have following form to post and update category name and images

 <h1>{{isset($image)?'Edit':'New'}}  Category</h1>

            <hr/>
            @if(isset($image))
    <form method="PUT" action="http://localhost:8000/update" enctype="multipart/form-data">
    <input type="hidden" name="_method" value="put">
@else
   <form method="POST" action="http://localhost:8000/create" accept-charset="UTF-8" enctype="multipart/form-data"><input name="_token" type="hidden" value="1LLYc0D1spmVSFMboLDjGM9MR4O5APVwng7giejx">
                                {{csrf_field()}}
@endif
                            
                                <div class="form-group row required{{ $errors->has('description') ? ' has-error' : '' }}">
                <label for="description" class="col-form-label col-md-3 col-lg-2">Description</label>
                <div class="col-md-8">
                    <input class="form-control" autofocus placeholder="Description" name="description" type="text" id="description" value="{{ isset($image) ? $image->categoryname : '' }}">
                                         @if ($errors->has('description'))
                    <span class="help-block">{{ $errors->first('description') }}</span>
                @endif
                    
                </div> 

            </div>

                        <div class="form-group row{{ $errors->has('image') ? ' has-error' : '' }}">
                <label for="image" class="col-form-label col-md-3">Image</label>
                <div class="col-md-5">
                    <img id="preview"
                         src="{{asset((isset($image) && $image->categoryimage!='')?'images/'.$image->categoryimage:'images/noimage.png')}}"
                         height="200px" width="200px"/>
                    <input class="form-control" style="display:none" name="image" type="file" id="image" name="_token" value="{{ csrf_token() }}">
                    <br/>
                    <a href="javascript:changeProfile();">Add Image</a> |
                    <a style="color: red" href="javascript:removeImage()">Remove</a>
                    <input type="hidden" style="display: none" value="0" name="remove" id="remove">
                     @if ($errors->has('image'))
                    <span class="help-block">{{ $errors->first('image') }}</span>
                @endif
                </div>
                
            </div>

and my update controller function for category is

 public function update(Request $request, $id)
    {

          if ($request->isMethod('get'))
            return view('categories.form', ['image' => Category::find($id)]);

         else {
            $rules = [
                'categoryname' => 'required',
            ];
            $this->validate($request, $rules);
        $image = Category::find($id);
            if ($request->hasFile('image')) {
                $dir = 'images/';
                if ($image->image != '' && File::exists($dir . $image->image))
                    File::delete($dir . $image->image);
                $extension = strtolower($request->file('image')->getClientOriginalExtension());
                $fileName = str_random() . '.' . $extension;
                $request->file('image')->move($dir, $fileName);
                $image->categoryimage = $fileName;
            } elseif ($request->remove == 1 && File::exists('images/' . $image->image)) {
                File::delete('images/' . $image->post_image);
                $image->categoryimage = null;
            }
        }
            $image->categoryname = $request->description;
            $image->save();
            return redirect()->route('categories.index');
    }

and route

Route::match(['get', 'put'], 'update/{id}', '[email protected]');

but when I go to edit form and give name or image and try to update it is occured following error msg

 (1/1) NotFoundHttpException 

how can I fix this problem?

30 Nov
1 month ago

Flex started a new conversation How To Count Table Column Data And Display In Google Bar Charts In Laravel?

working with Laravel 5.6 and mysql db. an I have table as vehicles like this?

id  name  type  
1   nhy   car
2   juy   van
3   nhy   car
4   kiu   bus
5   hyu   van
etc

currently I am displaying all vehicles numbers using following controller function,

public function vehiclebarchart()
    {
    $chart = Charts::database(Vehicle::all(), 'bar', 'google')
    ->elementLabel("Total")
    ->GroupByDay();
        return view('summarys.vehiclebarchart',compact('chart'));
    }

but now I need display each vehicles types in bar charts like car,van,bus... with counting then, how can I configure controller sql query like above query

$chart = Charts::database(Vehicle::all(), 'bar', 'google')

for my new requirements?

29 Nov
1 month ago

Flex started a new conversation How To Update Braintree Payment Dependency In Laravel 5.6?

I am working with Laravel 5.6 and using Braintree payment gateway sand box. but when I update my php version it is encounters some error. like this

Function create_function() is deprecated

in Util.php line 206

at HandleExceptions->handleError(8192, 'Function create_function() is deprecated', 'C:\Users\mala\Desktop\ddddd\vendor\braintree\braintree_php\lib\Braintree\Util.php', 206, array('string' => 'client_token', 'delimiter' => '-', 'callbacks' => array()))in Util.php line 206

so, I am using braintree vertion, ``` "oureastudios/laravel5-braintree": "dev-master" `` but when I search in internet most people suggested update braintree dependancy to v3.26.0. then My problem is how can I update My current braintree to above new vertion?

and I do not need update my laravel version

27 Nov
1 month ago

Flex left a reply on How To Count And Get Values Table Categoryname And Display Google Charts In Laravel 5

@signar accually google map called as following way in blade file,

@extends('layouts.app')
@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">Google Chart Demo</div>

<div class="panel-body">
                    {!! $chart->html() !!}
                </div>
            </div>
        </div>
    </div>
</div>
{!! Charts::scripts() !!}
{!! $chart->script() !!}
@endsection

Flex left a reply on How To Count And Get Values Table Categoryname And Display Google Charts In Laravel 5

@signar it id occured following error

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)

Flex started a new conversation How To Count And Get Values Table Categoryname And Display Google Charts In Laravel 5

working with laravel 5.6 and mysql db. I have table named as vehicles in my application like this, id name categoryname 1 lki Car 2 kio Van 3 hytg Car 4 hyu Truck 5 htg Van etc

Now I am going count numbers of each categoryname as Car 2 Van 2 Truck 1

and display Google Chart using consoletvs/charts. I have one example to displaying existing all users in controller as,

class BarChartController extends Controller
{
    public function index()
    {
    $chart = Charts::database(Vehicle::all(), 'bar', 'google')
    ->elementLabel("Total")
    ->GroupByMonth();
        return view('charts.bar',compact('chart'));
    }
}

so, now I need new controller function to show above my requirement (show each categorynames in charts) how can I configure controller for it?

24 Nov
1 month ago

Flex left a reply on What About New Look @laracast.com

@shamsweb yes I have same problem here?

19 Nov
2 months ago

Flex left a reply on How To Regex Validate Telephone Number?

@d9705996 actually I do not need international numbers. I need only my above conditions

Flex left a reply on How To Regex Validate Telephone Number?

@thyrosis now I using this one,

'telephone'    => 'required|regex:/(0)[0-9]{9}/'

all validation working without one that means I can enter more than 10 numbers with above validation

Flex started a new conversation How To Regex Validate Telephone Number?

working with Laravel 5.6 and have input box to store telephone number. existing validation is only required as following,

 $this->validate($request, [
          
            'telephone'    => 'required'
          

        ]);
but now I need validate with regex this telephone number with only 10 numbers and start only 0 number. how can I do this?
17 Nov
2 months ago

Flex left a reply on What About New Look @laracast.com

More Javascripts?

13 Nov
2 months ago

Flex left a reply on What About New Look @laracast.com

posting window is small than its need

12 Nov
2 months ago

Flex left a reply on Why Did Not Save Multiple Images With Controller Route Return?

@arthvrian did you mean this,

$photos = $request->file('files');
 
        if (!is_array($photos)) {
            $photos = [$photos];
        }
 
        if (!is_dir($this->photos_path)) {
            mkdir($this->photos_path, 0777);
        }
 
        for ($i = 0; $i < count($photos); $i++) {
            $photo = $photos[$i];
            $name = sha1(date('YmdHis') . str_random(30));
            $save_name = $name . '.' . $photo->getClientOriginalExtension();
            $resize_name = $name . str_random(2) . '.' . $photo->getClientOriginalExtension();
 
            Image::make($photo)
                ->resize(250, null, function ($constraints) {
                    $constraints->aspectRatio();
                })
                ->save($this->photos_path . '/' . $resize_name);
 
            $photo->move($this->photos_path, $save_name);
 
            $upload = new Upload();
            $upload->filename = $save_name;
            $upload->resized_name = $resize_name;
            $upload->original_name = basename($photo->getClientOriginalName());
            $upload->vehicle_id = $vehicle->id;
            $upload->save();
            return redirect()->route('categories.categorypost')->with('info','Your Advertisment has been created successfully');
        }
    }

Flex started a new conversation Why Did Not Save Multiple Images With Controller Route Return?

In my Laravel app I have form to save multiple images to save uploads table, my form as following,

<form method="post" action="{{url('form')}}" enctype="multipart/form-data"> 
            {{csrf_field()}}
<div class="form-group row required">
            <div class="field" align="left" >
            <h3>Upload  images</h3>
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            </div>
</div>

and controller store function is,

$photos = $request->file('files');

        if (!is_array($photos)) {
            $photos = [$photos];
        }

        if (!is_dir($this->photos_path)) {
            mkdir($this->photos_path, 0777);
        }

        for ($i = 0; $i < count($photos); $i++) {
            $photo = $photos[$i];
            $name = sha1(date('YmdHis') . str_random(30));
            $save_name = $name . '.' . $photo->getClientOriginalExtension();
            $resize_name = $name . str_random(2) . '.' . $photo->getClientOriginalExtension();

            Image::make($photo)
                ->resize(250, null, function ($constraints) {
                    $constraints->aspectRatio();
                })
                ->save($this->photos_path . '/' . $resize_name);

            $photo->move($this->photos_path, $save_name);

            $upload = new Upload();
            $upload->filename = $save_name;
            $upload->resized_name = $resize_name;
            $upload->original_name = basename($photo->getClientOriginalName());
            
            $upload->save();
return redirect()->route('categories.categorypost')->with('info','Your Advertisment has been created successfully');

but when I attach 4 images in above form. it is saving only one image. that attach to first input file. why other images are not saving to table. but when i remove return following codes

return redirect()->route('categories.categorypost')->with('info','Your Advertisment has been created successfully');

then I can save all images. but I need above controller return and saving all images. how can I do this?

Flex started a new conversation Why Did Not Save Multiple Images In To The Table In Laravel 5.6

In my Laravel app I have form to save multiple images to save uploads table, my form as following,

<form method="post" action="{{url('form')}}" enctype="multipart/form-data"> 
            {{csrf_field()}}
<div class="form-group row required">
            <div class="field" align="left" >
            <h3>Upload  images</h3>
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            <input type="file" class="files" name="files[]" multiple />
            </div>
</div>

and jquery for image,

<script>
     $(document).ready(function() {
  if (window.File && window.FileList && window.FileReader) {
    $(".files").on("change", function(e) {
      var clickedButton = this;
      var files = e.target.files,
        filesLength = files.length;
      for (var i = 0; i < filesLength; i++) {
        var f = files[i]
        var fileReader = new FileReader();
        fileReader.onload = (function(e) {
          var file = e.target;
          $("<span class=\"pip\">" +
            "<img class=\"imageThumb\" src=\"" + e.target.result + "\" title=\"" + file.name + "\"/>" +
            "<br/><span class=\"remove\">Remove image</span>" +
            "</span>").insertAfter(clickedButton);
          $(".remove").click(function(){
            $(this).parent(".pip").remove();
          });
          });
        fileReader.readAsDataURL(f);
      }
    });
  } else {
    alert("Your browser doesn't support to File API")
  }
});
 </script>

and controller store function is,

$photos = $request->file('files');

        if (!is_array($photos)) {
            $photos = [$photos];
        }

        if (!is_dir($this->photos_path)) {
            mkdir($this->photos_path, 0777);
        }

        for ($i = 0; $i < count($photos); $i++) {
            $photo = $photos[$i];
            $name = sha1(date('YmdHis') . str_random(30));
            $save_name = $name . '.' . $photo->getClientOriginalExtension();
            $resize_name = $name . str_random(2) . '.' . $photo->getClientOriginalExtension();

            Image::make($photo)
                ->resize(250, null, function ($constraints) {
                    $constraints->aspectRatio();
                })
                ->save($this->photos_path . '/' . $resize_name);

            $photo->move($this->photos_path, $save_name);

            $upload = new Upload();
            $upload->filename = $save_name;
            $upload->resized_name = $resize_name;
            $upload->original_name = basename($photo->getClientOriginalName());
            
            $upload->save();

but when I attach 4 images in above form. it is saving only one image. that attach to first input file. why other images are not saving to table. how can I fix this problem?

08 Nov
2 months ago

Flex left a reply on What About New Look @laracast.com

@puzbie I mean when we publish some post indicating time in the post.

Flex left a reply on What About New Look @laracast.com

what about time ago in the thered is it wrong or new one. I cant understand it

07 Nov
2 months ago

Flex left a reply on What About New Look @laracast.com

@theunforgiven what is Tailwind? actually Its new for me.

Flex left a reply on What About New Look @laracast.com

question answer window should be larger than existing...

Flex started a new conversation What About New Look @laracast.com

feeling change

01 Nov
2 months ago

Flex left a reply on Why Did Not Highlight Current Bootstrap Menu In Laravel 5.6?

@Snapey actually still My current menu item did not highlight

Flex left a reply on Why Did Not Highlight Current Bootstrap Menu In Laravel 5.6?

@Snapey please see my sidemenu blade file,

<style type="text/css">
  
 .nav-sidebar li.active{
  /*your css code here*/
 }
</style>




<nav class="navbar navbar-default">
  <ul class="nav nav-sidebar">
     
      <li class="{{Request::is('vehicles*') ? 'active' : null}}"><a href="{{route('vehicles.myads')}}">My Ads</a></li>
      </ul>
 </nav>

is this correct for color change for active class. still I did not paste style color here?

Flex started a new conversation Why Did Not Highlight Current Bootstrap Menu In Laravel 5.6?

I am working with Laravel 5.6 and using following sidemenu link as one of items as the app side menu,

<nav class="navbar navbar-default">
  <ul class="nav nav-sidebar">
     
      <li class="{{Request::is('vehicles*') ? 'active' : null}}"><a href="{{route('vehicles.myads')}}">My Ads</a></li>
      </ul>
 </nav>

and this sidemenu blade file is include with other blade files to show side menu, and above menu link route is following,

Route::get('myads', [
    'uses' => '[email protected]',
    'as'   => 'vehicles.myads',

]);

but when I visit myads blade file it is not highlight current menu items. how can fix this probelm?