/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     Item::truncate();
     DB::statement("SET foreign_key_checks = 1");
     $cause = Cause::where('cause_title', 'Liberation of minor sex')->get()->first();
     Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'blanket', 'item_description' => 'for minor sex', 'item_required' => 20, 'item_received' => 7, 'item_worth' => 11]);
     Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'bedsheets', 'item_description' => 'for minor sex', 'item_required' => 45, 'item_received' => 23, 'item_worth' => 9]);
     $cause = Cause::where('cause_title', 'Child Support')->get()->first();
     Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'books', 'item_description' => 'for child support', 'item_required' => 200, 'item_received' => 159, 'item_worth' => 14]);
     Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'desks', 'item_description' => 'for child support', 'item_required' => 100, 'item_received' => 67, 'item_worth' => 15]);
     //  $cause = Cause::where('cause_title',
     //  	'Flood Donation PK')->get()->first();
     //  Item::create([
     //  	'cause_id' => $cause->cause_id,
     //  	'item_name' => 'blanket',
     //  	'item_description' => 'for flood donation',
     //  	'item_required' => 500,
     //  	'item_received' => 322,
     //  	'item_worth' => 12
     // ]);
     // Item::create([
     // 	'cause_id' => $cause->cause_id,
     //  	'item_name' => 'clothes',
     //  	'item_description' => 'for flood donation',
     //  	'item_required' => 900,
     //  	'item_received' => 545,
     //  	'item_worth' => 15
     // ]);
     //  $cause = Cause::where('cause_title',
     //  	'Earthquake PK')->get()->first();
     //  Item::create([
     //  	'cause_id' => $cause->cause_id,
     //  	'item_name' => 'cash',
     //  	'item_description' => 'for earthquake',
     //  	'item_required' => 500000,
     //  	'item_received' => 123410,
     //  	'item_worth' => 1
     // ]);
     // Item::create([
     // 	'cause_id' => $cause->cause_id,
     //  	'item_name' => 'clothes',
     //  	'item_description' => 'for earthquake',
     //  	'item_required' => 100,
     //  	'item_received' => 67,
     //  	'item_worth' => 15
     // ]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     Cause::truncate();
     DB::statement("SET foreign_key_checks = 1");
     // $ngo = Ngo::where('ngo_name', 'Double A. ORG')->get()->first();
     // Cause::create([
     //   'user_id' => $ngo->user_id,
     //   'cause_title' => 'EarthQuake PK',
     //   'cause_venue' => 'ISLAMABAD',
     //   'cause_cover' => 'Optimal cover for cause.',
     //   'cause_description' => 'Raising fund for PK earthquake.'
     // ]);
     // Cause::create([
     //   'user_id' => $ngo->user_id,
     //   'cause_title' => 'Flood Donation PK',
     //   'cause_venue' => 'LAHORE',
     //   'cause_cover' => 'Optimal cover for flood water.',
     //   'cause_description' => 'Raising fund for Flood prevention.'
     // ]);
     $ngo = Ngo::where('ngo_name', 'Minus Z. ORG')->get()->first();
     Cause::create(['user_id' => $ngo->user_id, 'cause_title' => 'Child Support', 'cause_venue' => 'United Kingdom', 'cause_cover' => 'cover image for child', 'cause_description' => 'Raising fund for supporting child.']);
     Cause::create(['user_id' => $ngo->user_id, 'cause_title' => 'Liberation of minor sex', 'cause_venue' => 'Burma', 'cause_cover' => 'Burma cover image', 'cause_description' => 'Transport service for minorities.']);
 }
use App\Item;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::bind('ngo', function ($value) {
    return Ngo::where('user_id', $value)->first();
});
Route::bind('cause', function ($value) {
    return Cause::where('cause_id', $value)->first();
});
Route::bind('item', function ($value) {
    return Item::where('item_id', $value)->first();
});
Route::get('/', 'NgoController@index');
Route::get('/{ngo}', 'NgoController@ngoView');
Route::get('/cause/{cause}', 'NgoController@causeView');
Route::get('/causes/all', 'NgoController@viewAll');
Route::get('/{ngo}/contact-us', 'NgoController@contactView');
Route::post('/{ngo}/contact-us/message', 'NgoController@storeMessage');
Route::get('/auth/login', 'MyAuthController@getLogin');
// Route::get('/auth/login', 'MyAuthController@getLogin');
// Route::post('/auth/login', 'MyAuthController@postLogin');
Route::get('/auth/logout', 'MyAuthController@getLogout');
Route::post('/auth/login', 'MyAuthController@postLogin');
 public function viewAll()
 {
     $causes = Cause::all();
     return view('ngos.allView', ['causes' => $causes]);
 }
示例#5
0
 public function create($id)
 {
     $causes = Cause::select('id', 'name')->where(array('organisation_id' => $id, 'active' => 1))->lists('name', 'id');
     return view('donations.add_donation')->with('causes', $causes)->with('id', $id);
 }
示例#6
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id, $cause_id)
 {
     $cause = Cause::find(array('organisation_id' => $id, 'id' => $cause_id))->first();
     return view('cause.show')->with(array('cause' => $cause, 'id' => $id));
 }
 public function storeCause(Request $request, Ngo $ngo)
 {
     $cause = new Cause();
     $rules = ['title' => 'required|string|max:255', 'description' => 'required|string', 'venue' => 'string|min:5'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/envy/author/' . $ngo->user_id)->withErrors($validator);
     } else {
         $date = (new DateTime())->format('Y-m-d H:i:s');
         $cause->user_id = $ngo->user_id;
         $cause->cause_title = $request->title;
         $cause->cause_description = $request->description;
         $cause->cause_venue = $request->venue;
         $cause->started = $date;
         $cause->save();
         // return view('ngos.causeView', [
         //   'cause' => $cause,
         // ]);
     }
     $changed = false;
     foreach ([1, 2, 3, 4, 5] as $var) {
         if (Input::get('new-name-' . $var)) {
             $rules = ['new-name-' . $var => 'required|string', 'new-required-' . $var => 'integer', 'new-promised-' . $var => 'integer', 'new-received-' . $var => 'integer'];
             $validator = Validator::make(Input::all(), $rules);
             if ($validator->fails()) {
                 return redirect('/envy/author/' . $ngo->user_id)->withErrors($validator);
             } else {
                 $item = new Item();
                 $item->cause_id = $cause->cause_id;
                 $item->item_name = Input::get('new-name-' . $var);
                 $item->item_required = (int) Input::get('new-required-' . $var);
                 $item->item_promised = (int) Input::get('new-promised-' . $var);
                 $item->item_received = (int) Input::get('new-received-' . $var);
                 $item->save();
                 // $changed = true;
             }
         }
     }
     return view('ngos.causeView', ['cause' => $item->cause]);
 }