dimanche 17 juin 2018

Default value for a photo in laravel

Hi i'm trying to make a function that allows everyone to publish whatever they want but when the visitor is not a user his post photo's default will be a photo from my directory storage that holds the meaning of anonymous or something alike:

what is the SQL command line that allows me to do so?

My post migration table is:

   Schema::create('posts', function (Blueprint $table) {
        $table->increments('id');
         $table->string('title');
          $table->string('username');
         $table->string('body');
         $table->boolean('valid')->default(0);
          $table->string('photo',150)->nullable();
            $table->timestamps();
    });

My function store() is the following:

  public function store(Request $request)
    {

   $post= new Post();
   $post->title=$request->input('title');
   $post->photo=$request->photo; //what do i change in this field?
   $post->username=$request->input('username');
      $post->body=$request->input('body');
   $post->save();
   return redirect ('/ed');
}

Any ideas would be appreciated, thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire