I want to check whether the menu_id
consists the same order or not.
Suppose menu_id = 1
and order = 1
.
Then when the user wants to add same order (i.e. 1
), it must show error message.
If not the the value must be saved.
This is submenu table:
Schema::create('submenu', function (Blueprint $table) {
$table->increments('submenu_id');
$table->tinyInteger('status')->default(1);
$table->unsignedInteger('menu_id');
$table->string('name');
$table->tinyInteger('order');
$table->timestamps();
$table->foreign('menu_id')
->references('id')
->on('menu')
->onDelete('cascade');
});
I did this to check whether the menu_id
consists the order or not, however its not working.
Submenu controller -> addSubmenu()
function:
$order = Input::get('order');
$menu = Input::get('menu_id');
if($menu->contains($order)){
echo "exists";die;
} else {
echo "no exists";die;
}
You can use laravel eloquent to acheive this. Try:
Submenu::where('order', $order)->where('menu_id', $menu)->get();