I'm trying to allow a user to post an image to a database along with various other bits of information. It posts perfect. I'll show the code to how I post it.
When I try to display it, as shown in the template below, it returns the missing image icon, or if I have it as an h1, a path, but that path does not exist.
Is there something I'm doing wrong in the way i'm sending it the database that doesn't format it correctly. Controller
public function store(Request $request){
$Advert = new PropertyAdvert();
$Advert::create(
[
"photo" => $request->photo,
"address" => $request->address,
"county" => $request->county,
"town" => $request->town,
"type" => $request->type,
"rent" => $request->rent,
"date" => $request->date,
"bedrooms" => $request->bedrooms,
"bathrooms" => $request->bathrooms,
"furnished" => $request->furnished,
"description" => $request->description
]
);
return "Success. Your adveret has been published";
}
Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PropertyAdvert extends Model
{
protected $fillable = ["photo", "address", "county", "town","type","rent","date","bedrooms","bathrooms","furnished","description",];
}
Migration
public function up()
{
Schema::create('property_adverts', function (Blueprint $table) {
$table->increments('id');
$table->binary('photo');
$table->string('address');
$table->string('county');
$table->string('town');
$table->string('type');
$table->string('rent');
$table->string('date');
$table->string('bedrooms');
$table->string('bathrooms');
$table->string('furnished');
$table->longText('description');
$table->timestamps();
});
}
Template
<div>
<div class="row">
<div class="col-md-10">
<h1></h1>
<img src="">
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
</div>
</div>
@endsection
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire