MY DB structure is like this
CREATE TABLE `subscription_manager` (
`subscription_id` int(10) NOT NULL,
`user_id` int(10) NOT NULL,
`comic_id` int(10) NOT NULL,
`admin_id` int(10) NOT NULL,
`date_of_subscription` date NOT NULL,
`mini` tinyint(1) DEFAULT '0',
`one_shots` tinyint(1) NOT NULL DEFAULT '0',
`updated_at` date NOT NULL,
`created_at` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Here subscription_id is the table primary key.
I am using join here to fetch data from 3 tables.
public function index()
{
$fetch = DB::table('subscription_manager')
->join('comic_info', 'comic_info.id', '=', 'subscription_manager.comic_id')
->join('users', 'users.id', '=', 'subscription_manager.user_id')
->get();
for ($i = 0, $c = count($fetch); $i < $c; ++$i) {
$fetch[$i] = (array) $fetch[$i];
}
return view('comic/subcriptions', compact('fetch'));
}
and here the destroy method
public function destroy($id)
{
$subscribe = Subscription::find($id);
if ($subscribe != null)
{
$subscribe->delete();
return redirect('subscriptions')->with('message','Subscription Successfully Deleted');
}
else
{
return redirect('subscriptions')->with('message','Unable to Delete');
}
}
And delete action is look like inside view.
<form action="{{ action('SubscriptionController@destroy', $comic['subscription_id'])}}" method="post">
{{csrf_field()}}
<input name="_method" type="hidden" value="DELETE">
<button class="btn btn-danger" type="submit">Delete</button>
</form>
But when i going to delete the record it says
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'subscription_manager.id' in 'where clause' (SQL: select * from `subscription_manager` where `subscription_manager`.`id` = 191 limit 1)
That means its by default taking id only. I dont want delete from id. i want that from subscription_id.
How can i Fixed that issue thanks.