v0.0.2 You can now make post and store it in the database.
This commit is contained in:
parent
dfb9103157
commit
d276aed27b
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Backend\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
|
class Post extends Eloquent{
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'title','description'
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Backend\Model;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
class User extends Eloquent{
|
class User extends Eloquent{
|
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../bootstrap.php";
|
require_once "../../bootstrap.php";
|
||||||
|
|
||||||
|
use Backend\Model\User;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
//require our bootstrap file for database connection
|
||||||
|
require "../../bootstrap.php";
|
||||||
|
|
||||||
|
use Backend\Model\Post;
|
||||||
|
|
||||||
|
//Chek if the user did press the button on the home pages
|
||||||
|
if(isset($_POST['createPost'])){
|
||||||
|
//Grep the data from post
|
||||||
|
$title = $_POST['title'];
|
||||||
|
$description = $_POST['description'];
|
||||||
|
|
||||||
|
//Create a new initialize
|
||||||
|
$post = new Post();
|
||||||
|
|
||||||
|
//Call the Post class and save the user data to the database
|
||||||
|
$post->title = $title;
|
||||||
|
$post->description = $description;
|
||||||
|
|
||||||
|
//Call the save function.
|
||||||
|
if(!$post->save()){
|
||||||
|
echo "Failed to save the post";
|
||||||
|
exit();
|
||||||
|
}else{
|
||||||
|
echo "Post has been saved";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require "../../bootstrap.php";
|
||||||
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
|
||||||
|
Capsule::schema()->create('posts', function ($table) {//Note til mig selv, husk at din database table skal ende med "s" hvis du faa en lang fejl besked
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('title');
|
||||||
|
$table->longtext('description');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
require "user_migration.php";
|
//require "user_migration.php";
|
||||||
echo "Done";
|
//require "post_migration.php";
|
||||||
|
echo "Nothing required/Enabled ";
|
||||||
|
|
|
@ -6,7 +6,14 @@
|
||||||
<title>Home</title>
|
<title>Home</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Logget in</p>
|
|
||||||
<a href="../Backend/controller/logout.php">Log ud</a>
|
<p>Logget in som <?php echo $_SESSION['name'];?></p>
|
||||||
|
<a href="../Backend/controller/logout.php">Log ud</a>
|
||||||
|
<hr>
|
||||||
|
<form action="../Backend/controller/upload.php" method="POST">
|
||||||
|
<input type="text" name="title">
|
||||||
|
<input type="text" name="description">
|
||||||
|
<input type="submit" name="createPost" placeholder="Opret">
|
||||||
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"illuminate/database": "^8.44"
|
"illuminate/database": "^8.30",
|
||||||
|
"ext-mysqli": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"Backend/model"
|
"Backend/Model"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"name": "sde_skp/game_jaming",
|
||||||
|
"description": "description"
|
||||||
}
|
}
|
|
@ -7,11 +7,12 @@ $baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
||||||
|
'Backend\\Model\\Post' => $baseDir . '/Backend/Model/Post.php',
|
||||||
|
'Backend\\Model\\User' => $baseDir . '/Backend/Model/User.php',
|
||||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
||||||
'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
||||||
'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
||||||
'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
||||||
'User' => $baseDir . '/Backend/model/User.php',
|
|
||||||
'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -148,12 +148,13 @@ class ComposerStaticInitc851e149abcb24897d1e18cb056786d5
|
||||||
|
|
||||||
public static $classMap = array (
|
public static $classMap = array (
|
||||||
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
||||||
|
'Backend\\Model\\Post' => __DIR__ . '/../..' . '/Backend/Model/Post.php',
|
||||||
|
'Backend\\Model\\User' => __DIR__ . '/../..' . '/Backend/Model/User.php',
|
||||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
||||||
'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
||||||
'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
||||||
'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
||||||
'User' => __DIR__ . '/../..' . '/Backend/model/User.php',
|
|
||||||
'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue