123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Controllers\Admin;
- use Illuminate\Http\Request;
- use App\Http\Requests;
- use App\Http\Controllers\Controller;
- use App\Models\AccountType;
- use App\Models\AccountHead;
- use App\Models\Journal;
- use App\User;
- use App\Models\CompanyModel;
- class RevenueController extends Controller
- {
- function index()
- {
- $data['companies']=CompanyModel::where('status',2)->orderBy('name','asc')->get();
- $data['account_types']=AccountHead::where('type_id',1)->get();
- $data['credit_heads']=AccountHead::where('type_id',4)->get();
- $data['title']='Add Revenue';
- return view('admin.revenue.index',$data);
- }
- function store(Request $req)
- {
- $this->validate($req,[
- 'debit_head'=>'required',
- 'credit_head'=>'required',
- 'amount'=>'required|numeric'
- ]);
- $journal=new Journal();
- $journal->ref_id=$req->get('credit_head');
- $journal->debit_account=$req->get('debit_head');
- $journal->credit_account=$req->get('credit_head');
- $journal->description=$req->get('description');
- $journal->amount=$req->get('amount');
- $journal->is_approaved=0;
- $journal->created_by=\Auth::user()->id;
- $journal->created_at=$req->get('date',date('Y-m-d'));
- $journal->client_id=$req->get('client');
- $journal->save();
- $req->session()->flash('success','Revenue added successfully !');
- return redirect('account/revenue');
- }
- }
|