-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated version with database initial set up
- Loading branch information
Showing
52 changed files
with
5,355 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace P4; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Children extends Model | ||
{ | ||
public function user_parent() { | ||
# Child has one parent | ||
# Define a one-to-many relationship. | ||
return $this->belongsTo('\P4\UserParent'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace P4\Http\Controllers; | ||
require __DIR__ . '/../../../vendor/autoload.php'; | ||
use P4\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use P4\Http\Requests; | ||
use Auth; | ||
|
||
class ChildrenController extends Controller { | ||
public function getCreate() { | ||
$parent = \P4\User::where('email', '=', Auth::user() -> email) -> get() -> first(); | ||
/* | ||
$parent = \P4\Children::find(Auth::user() -> id); | ||
return view('parents.getparentsdetails') -> with(['parent' => $parent]);*/ | ||
return view('children.getchildrendetails') -> with(['parent' => $parent]); | ||
} | ||
|
||
public function getExisting(Request $request) { | ||
//$this -> validate($request, ['username' => 'required|string', 'password' => 'required|string', ]); | ||
$data = $request -> all(); | ||
$child = \P4\Children::where('user_parent_id', '=', $data['user_parent_id']) -> get() -> first(); | ||
if ($parent != null) { | ||
return view('children.showchildrendetails') -> with('child', $child); | ||
} else { | ||
\Session::flash('message', 'No such registered email adress! Please verify your username'); | ||
return redirect('/parents/login'); | ||
} | ||
} | ||
public function postCreate(Request $request) { | ||
|
||
$this -> validate($request, ['firstname' => 'required|string', 'lastname' => 'required|string', 'date_of_birth' => 'required|string', ]); | ||
|
||
$data = $request -> all(); | ||
/* | ||
$parent = \P4\UserParent::where('username', '=', $data['username']) -> get() -> first(); | ||
if ($parent != null) { | ||
\Session::flash('message', 'Username already exist! Please try login using your username'); | ||
return redirect('/parents/login'); | ||
} else { | ||
// Create new Parent | ||
$parent = new \P4\UserParent(); | ||
$parent -> firstname = $data['firstname']; | ||
$parent -> lastname = $data['lastname']; | ||
$parent -> username = $data['username']; | ||
$parent -> save(); | ||
} | ||
*/ | ||
|
||
return view('children.showchildrendetails') -> with(['child' => child]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.