Xnoar

Xnoar

Member Since 2 Weeks Ago

Experience Points 150
Experience Level 1

4,850 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-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

11 Aug
1 week ago

Xnoar started a new conversation How To Insert Records In 2 Related Tables Laravel 5.8

Good afternoon friends, I am doing a school project, I have a system in which I need to generate a quote, this quote is related to the client table, if I extract the data from the client table and put it in form to create no problem. However, it would not be practical to create the client separately. How could I do so that when creating the quote you can choose whether it is a new customer or one exists?

Quotation model

class quotation extends Model
   {

protected $table = 'quotations';

protected $fillable = [
   'description', 'price', 'tax', 'sub_total', 'total','quantity', 'client_id','product_id','coated_id','material_id'
];

public function client()
{
return $this->belongsTo('App\Client');
}

  }

Quotation Controller

  namespace App\Http\Controllers;

     use App\quotation;
     use Illuminate\Http\Request;
     use App\product;
     use App\Client;
     use App\coated;
     use App\material;


 class QuotationController extends Controller
{
/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    $quotations= quotation::paginate('10');

    return view('admin.quotations.index', compact('quotations'));
}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    
 $products = product::select('id','name')->orderBy('id')->get();
 $coateds = coated::select('id','name')->orderBy('id')->get();
 $materials = material::select('id','name')->orderBy('id')->get();
 $clients = Client::select('id','name')->orderBy('id')->get();
    return view('admin.quotations.create',compact('products','coateds','materials','clients'));
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
  
    $this->validate($request,[
        'description'=>'required',
        'price'=>'required',
        'tax'=>'required',
        'sub_total'=>'required',
        'total'=>'required',
        'quantity'=>'required',
        'client_id'=>'required',
        'product_id'=>'required',
        'material_id'=>'required',
        'coated_id'=>'required',

      ]);

     $requestValues = $request->all();
           $quotation = quotation::create([
              'description'=>$requestValues['description'],
              'price'=>$requestValues['price'],
              'tax'=>$requestValues['tax'],
              'sub_total'=>$requestValues['sub_total'],
              'total'=>$requestValues['total'],
              'quantity'=>$requestValues['quantity'],
              'client_id'=>$requestValues['client_id'],
              'product_id'=>$requestValues['product_id'],
              'material_id'=>$requestValues['material_id'],
              'coated_id'=>$requestValues['coated_id'],
              

            ]);

   
        
   return redirect()-> route('quotations.edit')->with('info','Cotizacion guardada con exito');
    
    }

Xnoar left a reply on Form Does Nothing Laravel 5.8

Sorry but I can't understand, I have to change the path in the web.php file

    Route::get('admin/quotations/{quotation}','[email protected]')->name('quotations.edit')
    ->middleware('can:quotations.edit');  

??

Xnoar left a reply on Form Does Nothing Laravel 5.8

If they are all within a route group to be displayed only if they are registered using the authentication method middleware

Route::middleware(['auth'])->group(function () {

    Route::get('admin/home',function(){
        return view('admin.home');
         })->name('admin');   

//----------------------------------Cotizaciones------------------------------------ Route::post('admin/quotations/store','[email protected]')->name('quotations.store') ->middleware('can:quotations.create');

    Route::get('admin/quotations','[email protected]')->name('quotations.index')
    ->middleware('can:quotations.index');

    Route::get('admin/quotations/create','[email protected]')->name('quotations.create')
    ->middleware('can:quotations.create');

    Route::put('admin/quotations/{quotation}','[email protected]')->name('quotations.update')
    ->middleware('can:quotations.edit');

    Route::get('admin/quotations/show/{quotation}','[email protected]')->name('quotations.show')
    ->middleware('can:quotations.show');

    Route::delete('admin/quotations/{quotation}','[email protected]')->name('quotations.destroy')
    ->middleware('can:quotations.destroy');

    Route::get('admin/quotations/{quotation}','[email protected]')->name('quotations.edit')
    ->middleware('can:quotations.edit');

Xnoar left a reply on Form Does Nothing Laravel 5.8

Thanks, we have corrected that but now it tells me that the Route [admin.quotations.edit] not defined.

Xnoar left a reply on Form Does Nothing Laravel 5.8

Placing dd first throws the following when I send

array:11 [ "_token" => "UEfjlakudyubKtjcVek0XtonXHxK9HsFJXpontCi" "description" => "Fabricacion de troquel para maquina random" "price" => "48000" "quantity" => "3" "sub_total" => "144000" "tax" => "16" "total" => "167040" "client_id" => "1" "product_id" => "1" "coated_id" => "1" "material_id" => "1" ]

Xnoar left a reply on Form Does Nothing Laravel 5.8

The form closing tag is below the submit button, the dd tried on the controller after creating

$requestValues = $request->all(); $quotation = quotation::create([ 'description'=>$requestValues['description'], 'price'=>$requestValues['price'], 'tax'=>$requestValues['tax'], 'subtotal'=>$requestValues['subtotal'], 'total'=>$requestValues['total'], 'quantity'=>$requestValues['quantity'], 'client_id'=>$requestValues['client_id'], 'product_id'=>$requestValues['product_id'], 'material_id'=>$requestValues['material_id'], 'coated_id'=>$requestValues['coated_id'],

            ]);

            dd($quotation);
        
  /*  return redirect()-> route('admin.quotations.edit', $quotation->id)->with('info','Cotizacion guardada con exito');*/

Sorry for my bad English I'm using translator.

Xnoar started a new conversation Form Does Nothing Laravel 5.8

I am developing a system of quotes with roles and permissions, the method of creating is not working, however it is a strange error because when doing the tests I insert the first record, but it did not do it with the following ones, it does not show error at the time of giving send only refreshes the page and does not insert the data.

When trying to do dd does not show anything, nor does it generate any error just refreshes the page.

controller

 public function create()
{
    
 $products = product::select('id','name')->orderBy('id')->get();
 $coateds = coated::select('id','name')->orderBy('id')->get();
 $materials = material::select('id','name')->orderBy('id')->get();
 $clients = Client::select('id','name')->orderBy('id')->get();
    return view('admin.quotations.create',compact('products','coateds','materials','clients'));
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $this->validate($request,[
        'description'=>'required',
        'price'=>'required',
        'tax'=>'required',
        'subtotal'=>'required',
        'total'=>'required',
        'quantity'=>'required',
        'client_id'=>'required',
        'product_id'=>'required',
        'material_id'=>'required',
        'coated_id'=>'required',

      ]);

     $requestValues = $request->all();
           $quotation = quotation::create([
              'description'=>$requestValues['description'],
              'price'=>$requestValues['price'],
              'tax'=>$requestValues['tax'],
              'subtotal'=>$requestValues['subtotal'],
              'total'=>$requestValues['total'],
              'quantity'=>$requestValues['quantity'],
              'client_id'=>$requestValues['client_id'],
              'product_id'=>$requestValues['product_id'],
              'material_id'=>$requestValues['material_id'],
              'coated_id'=>$requestValues['coated_id'],
              

            ]);
        
    return redirect()-> route('admin.quotations.edit', $quotation->id)->with('info','Cotizacion guardada con exito');
}

Model

 class quotation extends Model

{

protected $table = 'quotations';

protected $fillable = [
   'description', 'price', 'tax', 'sub_total', 'total','quantity', 'client_id','product_id','coated_id','material_id'
];

public function client()

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

Routes

Route::post('admin/quotations/store','[email protected]')->name('quotations.store')
    ->middleware('can:quotations.create');

    Route::get('admin/quotations','[email protected]')->name('quotations.index')
    ->middleware('can:quotations.index');

    Route::get('admin/quotations/create','[email protected]')->name('quotations.create')
    ->middleware('can:quotations.create');

    Route::put('admin/quotations/{quotation}','[email protected]')->name('quotations.update')
    ->middleware('can:quotations.edit');

    Route::get('admin/quotations/show/{quotation}','[email protected]')->name('quotations.show')
    ->middleware('can:quotations.show');

    Route::delete('admin/quotations/{quotation}','[email protected]')->name('quotations.destroy')
    ->middleware('can:quotations.destroy');

    Route::get('admin/quotations/{quotation}','[email protected]')->name('quotations.edit')
    ->middleware('can:quotations.edit');  

Views

@extends('admin.template')

@section('content')

Cotizaciones [Generar nueva Cotizacion]

{{ __('Registro de Cotizaciones') }} @if(count($errors)>0) @include('admin.partials.error') @endif {{csrf_field()}}
      <div class="form-group row">
          <label for="description" class="col-md-4 col-form-label text-md-right">{{ __('Descripcion') }}</label>

          <div class="col-md-6">
              <input  type="text" class="form-control" name="description" required>
          </div>
      </div>

      <div class="form-group row">
          <label for="client_id" class="col-md-4 col-form-label text-md-right">{{ __('Cliente') }}</label>

          <select name="client_id">

            @foreach ($clients as $client)
                <option value="{{$client->id}}">
                  {{$client->name}}

                </option>

            @endforeach
          </select>

      </div>

      <div class="form-group row">
        <label for="product_id" class="col-md-4 col-form-label text-md-right">{{ __('Producto') }}</label>

        <select name="product_id">

          @foreach ($products as $product)
              <option value="{{$product->id}}">
                {{$product->name}}

              </option>

          @endforeach
        </select>

    </div>

    <div class="form-group row">
        <label for="material_id" class="col-md-4 col-form-label text-md-right">{{ __('Material') }}</label>

        <select name="material_id">

          @foreach ($materials as $material)
              <option value="{{$material->id}}">
                {{$material->name}}

              </option>

          @endforeach
        </select>

    </div>

    <div class="form-group row">
        <label for="coated_id" class="col-md-4 col-form-label text-md-right">{{ __('Acabado') }}</label>

        <select name="coated_id">

          @foreach ($coateds as $coated)
              <option value="{{$coated->id}}">
                {{$coated->name}}

              </option>

          @endforeach
        </select>

    </div>
    <div class="form-group row">
      <label for="price" class="col-md-4 col-form-label text-md-right">{{ __('Precio') }}</label>

      <div class="col-md-6">
          <input  type="text" class="form-control price" name="price" onchange="multiplicar();" required>
      </div>
  </div>

    <div class="form-group row">
      <label for="quantity" class="col-md-4 col-form-label text-md-right">{{ __('Cantidad') }}</label>

      <div class="col-md-6">
          <input  type="text" class="form-control quantity" name="quantity" onchange="multiplicar();" required>
      </div>
  </div>

  <div class="form-group row">
    <label for="sub_total" class="col-md-4 col-form-label text-md-right">{{ __('Subtotal') }}</label>

    <div class="col-md-6">
        <input  type="text" class="form-control subtotal" name="sub_total" required>
    </div>
</div>

    <div class="form-group row">
        <label for="tax" class="col-md-4 col-form-label text-md-right">{{ __('Impuesto') }}</label>

        <div class="col-md-6">
            <input  type="text" class="form-control tax" name="tax" onchange="multiplicar();" required>
        </div>
    </div>

    <div class="form-group row">
      <label for="total" class="col-md-4 col-form-label text-md-right">{{ __('Total') }}</label>

      <div class="col-md-6">
          <input  type="text" class="form-control total" name="total" required>
      </div>
  </div>


      <button type="submit" class="btn btn-info">Agregar Articulo</button>
    </form>

          </div>
      </div>
  </div>
function multiplicar (){ input1 = document.querySelector(".quantity").value; input2 = document.querySelector(".price").value; input3 = document.querySelector(".tax").value; subtotal = parseInt(input1)*parseInt(input2); impuesto = parseInt(subtotal)*parseInt(input3)/100; document.querySelector(".subtotal").value = subtotal; document.querySelector(".total").value = subtotal+impuesto;

}

@endsection