jeudi 24 août 2017

if condition for unique title name else create new in laravel

i am using laravel i want to use if condition in my controller
if product title is already exist in my table so get product id else create new title and get get product id Here is my table

 $table->increments('id');
        $table->timestamps();
        $table->string('image');
        $table->string('stock');
        $table->string('title');
        $table->string('slug')->unique();
        $table->string('gender');
        $table->text('description');
        $table->integer('price');
        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')
                    ->onDelete('restrict')
                    ->onUpdate('restrict');
        $table->integer('designer_id')->unsigned();
        $table->foreign('designer_id')->references('id')->on('designers')
                    ->onDelete('restrict')
                    ->onUpdate('restrict');
        $table->dateTime('published_at');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire