delete test data in laravel migration script
<p>I am trying to clean the test data from my production tables. In simple environment I can write a script to clean the test data but I wonder how can I do the same in laravel migration script</p>

<p>I have a test user on production and want to clean all related records generated in the database.In a seed file I can fetch student id based on email address and then remove courses and other info based on the id?. I don't know if it sounds like a laravel way of doing things!</p>

<p>studentId = 101</p>

<p>He is enrolled to three courses
He has attendance records
He has communication records</p>

<p>Now I want to fetch student id based on his emailId
then want to delete records from courses, attendance, communication table
and finally delete id from student table</p>

<p>I am doing</p>

<pre><code>$sdetail = student::where('email','some@test.com')-&gt;first();
echo "you are checking fir: ".$sdetail -&gt;id;
$classes= class::where('studentId',"$sdetail-&gt;id")-&gt;get();
foreach($classes as $class)
{
    echo $class-&gt;name;   //print only one record I have three rec!
    DB::table('courses')-&gt;where("id",$class-&gt;id)-&gt;delete();
}
</code></pre>

<p>any idea fix this!</p>