jeudi 9 juillet 2020

implementing payu webcheckout laravel

Good I have three plans from which the user can choose which one to buy, but I would like to do everything in a single form, that the price, name and description of the plan are dynamic, but it gives me an error when passing the variable to view

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Plan;
use Laracasts\Flash\Flash;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;

class PlanController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        
        $plans = Plan::orderBy('id','ASC')->paginate(5);
        return view('admin.plans.index', ['plans' => $plans]);
        
    }
 

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $plans = Plan::all();
        return view('admin.plans.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $plans = new Plan($request->all());
        $plans->save();

        flash("Se ha registrado " . $plans->name .  " De forma exitosa ")->success();

        return redirect()->route('plans.index');
    }

    /**
     * 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)
    {
        $plans = Plan::findOrFail($id);
        return view ('admin.plans.edit',compact('plan_types','plans'));
    }
    
    

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $plans = Plan::findOrFail($id);
        $plans->update([
            'name' => $request->name,
        ]);
    
        flash("Se ha actualizado " . $plans->name  . " De forma exitosa ")->success();
    
        return redirect()->route('plans.index');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $plan = Plan::findOrFail($id);
        $plan->delete();
       
        flash('Se ha Eliminado el plan ' . $plan->name . ' Ha sido borrado de forma exitosa ')->important();
       
        return redirect()->route('plans.index');
    }
    
    public function payment($id)
    {
        $plans = Plan::findOrFail($id);
        dd($plans);
        return view('plans',compact('plans'));
        
    }
    
       
    public function planView()
    {
        return view('plans');
    }
    
    
    
    public function getPlan() 
    {
        $plans = Plan::get();
        return response()->json($plans);
    }
    
    
    
}

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('auth/redirect/{provider}','SocialController@redirect');
Route::get('auth/callback/{provider}','SocialController@handleCallback');


Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');



//route group, for the admin section, the resources routes contain all the methods


Route::group(['prefix' => 'admin'], function(){

    Route::resource('users', 'UsersController');
    
    Route::resource('plans', 'PlanController');
    
});

//route group, for the properties section, the resources routes contain all the methods

Route::group(['prefix' => 'properties'], function(){
    Route::get('/municipalities/{id}','PropertyController@getMunicipalities');
    Route::resource('owner', 'PropertyController');
   
});

//route , for the plan section, the resources routes contain all the methods

Route::get('/plans', 'PlanController@planView');

Route::get('/payment/{id}', 'PlanController@payment');

//route , for the profile section, the resources routes contain all the methods

Route::get('/profile', 'ProfileController@index');

//route , for the logs errors section, the resources routes contain all the methods

Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');

in my database I have three plans, gold, silver, bronze



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire