mannai

mannai

Member Since 2 Years Ago

Experience Points 1,710
Experience Level 1

3,290 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 15
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.

30 Sep
1 year ago

mannai left a reply on Updating User Email And Password

@shez1983 can u give some example of code !!

mannai left a reply on Updating User Email And Password

@shez1983 can u give some example of code !!

mannai started a new conversation Updating User Email And Password

i want to update password and/or email (depend on the user choice) , so i create tow forms in the same view , the first form the passwords (current_password , new_password , confirm_password) and other for the email(new_email, confirm_email, password) , and i put the logic in one controller , so the problem is when i wanna update one of them(ex: password ) email get null and vice-versa , until i found this solution https://laracasts.com/discuss/channels/laravel/help-updating-user-email-and-password , i create a request file where i put the logic , but it doesn't work (it redirect me to the profile without a test)

my setting form looks like this:

@extends('layouts.main')
@section('title','my profile')
@section('conten')
<div class="row">

     
  <div class="col-md-6 col-md-offset-3">
{!! Form::model(['route'=>['profile.setting'],'method'=>'post', 'files'=>true])!!}

    <div class="form-group">
    {!! Form::label('email', 'New Email:') !!}
    {!! Form::text('email', null, ['class' => 'form-control','placeholder'=>'your old email is  : '  .  Auth::user()->email,'required'=>'required']) !!}
        <span>{!! $errors->first('email') !!}</span>
    </div>
    <div class="form-group">
    {!! Form::label('confirm_email', 'Confirm New Email:') !!}
    {!! Form::text('confirm_email', null, ['class' => 'form-control','required'=>'required']) !!}
                              <span>{!! $errors->first('confirm_email') !!}</span>
    </div>
    <div class="form-group">
    {!! Form::label('password', 'Your Password:') !!}
    {!! Form::password('passworde',['class' => 'form-control','required'=>'required']) !!}
                              <span>{!! $errors->first('passworde') !!}</span>
    </div>
    {{ Form::submit('save changes',array('class'=>'btn btn-primary'))}}
</div>
</div>
{!! Form::close() !!}
</br></br>
</br>
</br>

<div class="row">

  <div class="col-md-6 col-md-offset-3">
{!! Form::model(['route'=>['profile.setting'],'method'=>'POST', 'files'=>true])!!}
    <div class="form-group">
    {!! Form::label('password', 'Current Password:') !!}
    {!! Form::password('password',['class' => 'form-control','required'=>'required']) !!}
                                  <span>{!! $errors->first('password') !!}</span>

    </div>

    <div class="form-group">
    {!! Form::label('password', 'New Password:') !!}
    {!! Form::password('new_password',['class' => 'form-control','required'=>'required']) !!}
                                  <span>{!! $errors->first('new_password') !!}</span>

    </div>

    <div class="form-group">
    {!! Form::label('password', 'Confirm New Password:') !!}
    {!! Form::password('verify_password', ['class' => 'form-control','required'=>'required']) !!}
                                  <span>{!! $errors->first('verify_password') !!}</span>

    </div>
{{ Form::submit('save changes',array('class'=>'btn btn-primary'))}}
{!! Form::close() !!}

</div>
</div>

</br>

</br>

</br>

</br>

</br>
@endsection


My User request:


<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class user extends FormRequest
{
  /**
   * Determine if the user is authorized to make this request.
   *
   * @return bool
   */
  public function authorize()
  {
      return false;
  }

  /**
   * Get the validation rules that apply to the request.
   *
   * @return array
   */
  public function rules()
  {
      $rules = array();

      if ( $this->request->has( 'password' ) && 0 == strlen( $this->request->get( 'password' ) ) ) {
          // no new password has been submitted, so the user doesn't want to change the password
          $this->request->remove( 'password' );
          

      } else {
          $rules['password']='min:4|validpassword';
          $rules['new_password'] = 'min:4|different:password';
          $rules['verify_password']='same:new_password';
      }

   

      if ( $this->request->has( 'email' ) && 0 == strlen( $this->request->get( 'email' ) ) ) {
          // no e-mail address has been submitted
          $this->request->remove( 'email' );
          
      } else {
          // a new e-mail address has been submitted, make sure it doesn't already exist
          $rules['email'] = 'email|unique:users,email,'.Auth::user()->id;
          $rules['confirm_email']='same:email';
           $rules['passworde']='min:4|validpassword';
       }



      return $rules;
  }
  }
}

My UserController


  
public function SettingProfile(user $request){

   
      $setting = Auth::user();
      $setting->update([
      'email'         =>  $request->email,
      'password'      =>  bcrypt($request->input('new_password')),
  ]);
      
      flash('Your settings has been updated')->success();
      return redirect()->route('user.profile');

}



03 May
2 years ago

mannai left a reply on MethodNotAllowedHttpException In RouteCollection.php

@thykus thank you for replying

the form that i posting to is this (admin.edit)

{!! Form::model(['route'=>'product.update','method'=>'PATCH','files'=>true])!!} {{Form::label('name','Name')}} {{Form::text('name',null,['class'=>'form-control','placeholder'=>$products->name])}} {{Form::label('description','Description')}} {{Form::text('description',null,['class'=>'form-control','placeholder'=>$products->description])}} {{Form::label('dimensions','Dimensions')}} {{Form::select('dimensions',['small'=>'small','medium'=>'medium','Big'=>'Big'],null,['class'=>'form-control',$products->dimensions])}} {{Form::label('image','Image')}} {{Form::file('image',array('class'=>'form-control'))}} {{Form::label('price','Price')}} {{Form::text('price',null,['class'=>'form-control','placeholder'=>$products->price])}} {{Form::label('qty','Qty')}} {{Form::text('qty',null,['class'=>'form-control','placeholder'=>$products->qty])}} {{Form::label('category_id','Categries')}} {{Form::select('category_id',$categories,null,['class'=>'form-control','placeholder'=>'Select category'])}}

{{ Form::submit('Update',array('class'=>'btn btn-primary'))}} {!! Form::close()!!}

as you see i mapped the update function in the controller with 'PATCH'

for more clarity those the functions edit and update in the controller

public function edit($id) {

    $products=Product::find($id);
    $categories=Category::pluck('name','id');
    return view('admin.product.edit',compact('categories','products'));
 
      
}

  

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

    $this->validate($request,[
        'name'=>'required',
        'description'=>'required',
        'dimensions'=>'required',
        'price'=>'required',
        'qty'=>'required',
        'image'=>'image|mimes:png,jpg,jpeg|max:10000|required'
        ]);

    $product=Product::find($id);
    $product->update($request->all());
    return redirect()->route('admin.product.index')->with('message','item has been updated successfully');
}

mannai left a reply on MethodNotAllowedHttpException In RouteCollection.php

@EventFellows

this is ther result of php artisan route:list i think its oki

| | GET|HEAD | admin/product | product.index | App\Http\Controllers\[email protected] | web,auth,admin | | | POST | admin/product | product.store | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/create | product.creat e | App\Http\Controllers\[email protected] | web,auth,admin | | | PUT|PATCH | admin/product/{product} | product.update e | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/{product} | product.show | App\Http\Controllers\[email protected] | web,auth,admin | | | DELETE | admin/product/{product} | product.destroy oy | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/{product}/edit | product.edit | App\Http\Controllers\[email protected] | web,auth,admin |

@tykus

i changed as you demand and when i click edit i get this url (product/1/edit) but when i fill the form and submit i get the same error

MethodNotAllowedHttpException in RouteCollection.php line 251:

02 May
2 years ago

mannai left a reply on MethodNotAllowedHttpException In RouteCollection.php

@EventFellows

this is ther result of php artisan route:list i thinks its oki

| | GET|HEAD | admin/product | product.inde | App\Http\Controllers\[email protected] | web,auth,admin | | | POST | admin/product | product.stor | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/create | product.crea e | App\Http\Controllers\[email protected] | web,auth,admin | | | PUT|PATCH | admin/product/{product} | product.upda e | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/{product} | product.show | App\Http\Controllers\[email protected] | web,auth,admin | | | DELETE | admin/product/{product} | product.dest oy | App\Http\Controllers\[email protected] | web,auth,admin | | | GET|HEAD | admin/product/{product}/edit | product.edit | App\Http\Controllers\[email protected] | web,auth,admin |

@tykus

i changed as you demand and when i click edit i get this url (product/1/edit) but when i fill the form and submit i get the same error

MethodNotAllowedHttpException in RouteCollection.php line 251:

mannai started a new conversation MethodNotAllowedHttpException In RouteCollection.php

the route : Route::resource('product','ProductsController'); this is ProductsController:

public function edit($id) {

    $products=Product::find($id);
    $categories=Category::pluck('name','id');
    return view('admin.product.edit',compact('categories','products'));
   
      
}


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

    $this->validate($request,[
        'name'=>'required',
        'description'=>'required',
        'dimensions'=>'required',
        'price'=>'required',
        'qty'=>'required',
        'image'=>'image|mimes:png,jpg,jpeg|max:10000|required'
        ]);

    $product=Product::find($id);
    $product->save($request->all());
    return redirect()->route('admin.product.index')->with('message','item has been updated successfully');
}

this is the index page :

    <table class="table table-hover">


        <thead>
        <tr>
           
            <th>Category Name</th>
            <th>Product Name</th>
           
            <th>Update</th>
            <th>Delete</th>
        </tr>
        </thead>
        <tbody>
        @foreach($products as $product)
            <tr>
                 
              
                <td>{{count($product->category)?$product->category->name:"N/A"}}</td>
                  <td>"{{link_to_route('product.show',$product->name,$product->id)}}" </td>

                <td>
                  
                    <form action="{{route('product.edit',$product->id,)}}" method="GET">
                         {{csrf_field()}}
                         {{method_field('PUT')}}
                         <input class="btn btn-sm btn-primary" type="submit" value="Update">
                    </form>
                </td>
                  <td>
                  
                    <form action="{{route('product.destroy',$product->id)}}"  method="POST">
                         {{csrf_field()}}
                         {{method_field('DELETE')}}
                         <input class="btn btn-sm btn-danger" type="submit" value="Delete">
                    </form>
                </td>

            </tr>
        @endforeach
        <tr>

            <td></td>
         
            <td></td>
            <td></td>

        </tr>

        </tbody>
    </table>


</div>

and this is the edit view :

Update product

{!! Form::model(['route'=>'product.update','method'=>'PUT','files'=>true])!!} {{Form::label('name','Name')}} {{Form::text('name',null,['class'=>'form-control','placeholder'=>$products->name])}} {{Form::label('description','Description')}} {{Form::text('description',null,['class'=>'form-control','placeholder'=>$products->description])}} {{Form::label('dimensions','Dimensions')}} {{Form::select('dimensions',['small'=>'small','medium'=>'medium','Big'=>'Big'],null,['class'=>'form-control',$products->dimensions])}} {{Form::label('image','Image')}} {{Form::file('image',array('class'=>'form-control'))}} {{Form::label('price','Price')}} {{Form::text('price',null,['class'=>'form-control','placeholder'=>$products->price])}} {{Form::label('qty','Qty')}} {{Form::text('qty',null,['class'=>'form-control','placeholder'=>$products->qty])}} {{Form::label('category_id','Categries')}} {{Form::select('category_id',$categories,null,['class'=>'form-control','placeholder'=>'Select category'])}}

{{ Form::submit('Update',array('class'=>'btn btn-primary'))}} {!! Form::close()!!}

01 May
2 years ago

mannai left a reply on Increment_id

@endian i thinked in this solution but as i said the request of a user for a specific product should be with more fields than a normal like width length poids a description ect

mannai left a reply on Increment_id

@topvillas thanks , @Snapey , i dont have another choise because i must i have two tables normal_product and specific_product , the normal is made by the admin who can create normal products, so those products will shows on the site to users whos can add any product to the cart and continue the process of bying. but the specific product will be create by the users witch they can specify their order , and those products will shows on only for the user who create it , so whats your opinion : lol

mannai started a new conversation Increment_id

hey , i would know if its possible to increment an (table_id) on depends of other condition, for exemple i have two tables: 1-productsSimple 2-productsSpecific when i create a new productsSimple the id =1 and when i create a new productsSpecific( the id will be 1) but i want it to be id=2 and vice versa

27 Apr
2 years ago

mannai left a reply on Stripe Token Error !

@fraserk so what i should do ??

mannai left a reply on Stripe Token Error !

yep i have this array:1 [▼ "_token" => "u0AH5A3sm71e6ejurUKw7JDZpYCTrNgU0cE7p3Dp" ]

mannai left a reply on Stripe Token Error !

i get null

mannai left a reply on Stripe Token Error !

@fraserk , i checked the ApiKey and still have the same problem even i create another stripe account but same, this is the test data POST /v1/charges 2017/04/27 16:46:02 Summary

ID: req_AYLV0SsASWNHhO Time: 2017/04/27 16:46:02 Method: POST URL: /v1/charges Status: 400 IP address: 197.9.6.143 Version: 2017-04-06 (latest) Source: Stripe/v1 PhpBindings/4.8.1

Parsed Request Query Parameters No query parameters Parsed Request POST Body

{ "amount": "10500", "currency": "usd", "description": "Example charge" }

Response body

{ "error": { "type": "invalid_request_error", "message": "Must provide source or customer." }

mannai left a reply on Stripe Token Error !

@fraserk sorry , but i have the same code as erenergul

this is the view

        <span class="payment-errors"></span>

        <div class="form-row">
            <label>
                <span>Card Number</span>
                <input type="text" size="20" data-stripe="number">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>Expiration (MM/YY)</span>
                <input type="text" size="2" data-stripe="exp_month">
                <span> / </span>
                <input type="text" size="2" data-stripe="exp_year">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>CVC</span>
                <input type="text" size="4" data-stripe="cvc">
            </label>
        </div>


        <input type="submit" class="submit button success" value="Submit Payment">
    </form>
    </div>
</div>

and this is the controller

// Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey("sk_test_0Uex74Tgikui4g7esQLg8NEy");

// Get the credit card details submitted by the form $token = $request->stripeToken;

// Create a charge: this will charge the user's card try { $charge = \Stripe\Charge::create(array( "amount" => Cart::total()*100, // Amount in cents "currency" => "usd", "source" => $token, "description" => "Example charge" )); } catch (\Stripe\Error\Card $e) { // The card has been declined }

mannai left a reply on Stripe Token Error !

and this is the controller

mannai left a reply on Stripe Token Error !

@fraserk i have the same code as @erenrgul

this is the view

@extends('layouts.main')

@section('content') {{csrf_field()}}

        <div class="form-row">
            <label>
                <span>Card Number</span>
                <input type="text" size="20" data-stripe="number">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>Expiration (MM/YY)</span>
                <input type="text" size="2" data-stripe="exp_month">
                <span> / </span>
                <input type="text" size="2" data-stripe="exp_year">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>CVC</span>
                <input type="text" size="4" data-stripe="cvc">
            </label>
        </div>


        <input type="submit" class="submit button success" value="Submit Payment">
    </form>
    </div>
</div>

@endsection

mannai left a reply on Stripe Token Error !

@fraserk hey , accually im facing same error and when i try printing it with dd(...) i see if it is null