The below one is my controller code from AdminController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Schema;
use Illuminate\Database\Schema\Blueprint;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;
use Session;
use Redirect;
use Response;
use App\KGB;
class AdminController extends Controller
{
public function add_kgb()
{
$kgb_type = Input::get('kgb_type');
$kgb_price = Input::get('kgb_price');
$region_id = Input::get('region_id');
$brand_id = Input::get('brand_id');
$count = KGB::count();
$kgb_id = "KGB".sprintf("%05d", ($count+1));
$add_kgb = new KGB;
$add_kgb->kgb_id = $kgb_id;
$add_kgb->kgb_type = $kgb_type;
$add_kgb->kgb_price = $kgb_price;
$add_kgb->region_id = $region_id;
$add_kgb->brand_id = $brand_id;
$add_kgb->flag = '1';
$add_kgb->save();
Session::flash('kgb_success','Successfully Added KG Billing!');
return Redirect::to('kgb');
}
public function edit_kgb()
{
$kgb_type = Input::get('kgb_type');
$kgb_price = Input::get('kgb_price');
$region_id = Input::get('region_id');
$brand_id = Input::get('brand_id');
$kgb_id = Input::get('kgb_id');
KGB::where('kgb_id', $kgb_id)->update(array('kgb_type' => $kgb_type, 'kgb_price' => $kgb_price, 'region_id' => $region_id, 'brand_id' => $brand_id));
Session::flash('kgb_success_edit','Successfully Edited KG Billing!');
return Redirect::to('kgb');
}
public function kgb_status($id)
{
$status = KGB::where('id',$id)->pluck('status');
if($status=='0')
KGB::where('id',$id)->update(array('status' => '1'));
else
KGB::where('id',$id)->update(array('status' => '0'));
Session::flash('kgb_success_status','Successfully Edited KG Billing!');
return Redirect::to('kgb');
}
}
This is my base controller code
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController
{
use DispatchesJobs, ValidatesRequests;
}
And this is my route code
Route::get('kgb', function () {
return view('admin.kgb');
});
Route::post('add_kgb', 'AdminController@add_kgb');
Route::post('edit_kgb', 'AdminController@edit_kgb');
Route::get('kgb_status/{id}', 'AdminController@kgb_status');
this one is my model
namespace App;
use Illuminate\Database\Eloquent\Model;
class KGB extends Model
{
protected $table = 'kg_billing';
}
Till now all my controllers and routes are working but now this method is throwing an error. Please help me out
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire